Browse Source

Refactor remote command (#13809)

* Refactor remote command

* Rename Command to Message
3.2.0-release
Wenjun Ruan 2 years ago committed by GitHub
parent
commit
68660ec96b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 35
      dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertRequestProcessor.java
  2. 20
      dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
  3. 32
      dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java
  4. 92
      dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/AlertServerTest.java
  5. 60
      dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/processor/AlertRequestProcessorTest.java
  6. 32
      dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/runner/AlertSenderServiceTest.java
  7. 4
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/aspect/CacheEvictAspect.java
  8. 6
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/executor/workflow/instance/pause/pause/PauseExecuteFunction.java
  9. 6
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/executor/workflow/instance/stop/StopExecuteFunction.java
  10. 6
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/rpc/ApiRpcClient.java
  11. 59
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
  12. 8
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/MetricsCleanUpServiceImpl.java
  13. 8
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java
  14. 5
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecuteFunctionServiceTest.java
  15. 10
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumer.java
  16. 2
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutorDispatcher.java
  17. 12
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/context/ExecutionContext.java
  18. 37
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManager.java
  19. 20
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskDelayEventHandler.java
  20. 6
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskRejectByWorkerEventHandler.java
  21. 4
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskResultEventHandler.java
  22. 17
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskRunningEventHandler.java
  23. 5
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskStateEventHandler.java
  24. 2
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskUpdatePidEventHandler.java
  25. 31
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/CacheProcessor.java
  26. 45
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/StateEventProcessor.java
  27. 25
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskExecuteResultProcessor.java
  28. 22
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskExecuteRunningProcessor.java
  29. 34
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskExecuteStartProcessor.java
  30. 66
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskForceStartProcessor.java
  31. 22
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskKillResponseProcessor.java
  32. 20
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskRecallProcessor.java
  33. 28
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskUpdatePidProcessor.java
  34. 24
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskWakeupProcessor.java
  35. 27
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/WorkflowExecutingDataRequestProcessor.java
  36. 23
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/WorkflowMetricsCleanUpProcessor.java
  37. 4
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java
  38. 16
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskEvent.java
  39. 76
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/rpc/MasterRPCServer.java
  40. 8
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/rpc/MasterRpcClient.java
  41. 33
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/StreamTaskExecuteRunnable.java
  42. 14
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteRunnable.java
  43. 6
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThreadPool.java
  44. 4
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/CommonTaskProcessor.java
  45. 6
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/SubTaskProcessor.java
  46. 4
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/MasterMessageTest.java
  47. 10
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutionContextTestUtils.java
  48. 4
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutorDispatcherTest.java
  49. 12
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManagerTest.java
  50. 10
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/CacheProcessorTest.java
  51. 6
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskAckProcessorTest.java
  52. 26
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskKillResponseProcessorTest.java
  53. 8
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseServiceTest.java
  54. 41
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/NettyRemotingClient.java
  55. 11
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/NettyRemotingServer.java
  56. 40
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/codec/NettyDecoder.java
  57. 12
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/codec/NettyEncoder.java
  58. 4
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/BaseMessage.java
  59. 67
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CacheExpireCommand.java
  60. 20
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/Message.java
  61. 6
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/MessageContext.java
  62. 2
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/MessageHeader.java
  63. 18
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/MessageType.java
  64. 27
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/RequestMessageBuilder.java
  65. 35
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/ResponseMessageBuilder.java
  66. 18
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/StateEventResponse.java
  67. 49
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/StateEventResponseCommand.java
  68. 42
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskStateEventResponseCommand.java
  69. 23
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendRequest.java
  70. 33
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponse.java
  71. 41
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/cache/CacheExpireRequest.java
  72. 18
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetAppIdRequest.java
  73. 17
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetAppIdResponse.java
  74. 44
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesRequest.java
  75. 55
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesRequestCommand.java
  76. 45
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponse.java
  77. 57
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponseCommand.java
  78. 23
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogRequest.java
  79. 23
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogResponse.java
  80. 23
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogRequest.java
  81. 24
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogResponse.java
  82. 23
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/ViewLogRequest.java
  83. 56
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/ViewLogResponseCommand.java
  84. 44
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/ViewLogResponseResponse.java
  85. 18
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskDispatchMessage.java
  86. 23
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteResultMessage.java
  87. 23
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteResultMessageAck.java
  88. 23
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteRunningMessage.java
  89. 56
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteRunningMessageAck.java
  90. 23
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteStartMessage.java
  91. 35
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskForceStartRequest.java
  92. 23
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskKillRequest.java
  93. 23
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskKillResponse.java
  94. 23
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskRejectMessage.java
  95. 23
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskRejectMessageAck.java
  96. 23
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskSavePointRequest.java
  97. 23
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskSavePointResponse.java
  98. 23
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskUpdatePidAckMessage.java
  99. 23
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskUpdatePidMessage.java
  100. 44
      dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskWakeupRequest.java
  101. Some files were not shown because too many files have changed in this diff Show More

35
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertRequestProcessor.java

@ -17,12 +17,10 @@
package org.apache.dolphinscheduler.alert; package org.apache.dolphinscheduler.alert;
import static com.google.common.base.Preconditions.checkArgument; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.alert.AlertSendRequest;
import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponse;
import org.apache.dolphinscheduler.remote.command.alert.AlertSendRequestCommand;
import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponseCommand;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.remote.utils.JsonSerializer; import org.apache.dolphinscheduler.remote.utils.JsonSerializer;
@ -43,20 +41,21 @@ public final class AlertRequestProcessor implements NettyRequestProcessor {
} }
@Override @Override
public void process(Channel channel, Command command) { public void process(Channel channel, Message message) {
checkArgument(CommandType.ALERT_SEND_REQUEST == command.getType(), "invalid command type: %s", AlertSendRequest alertSendRequest = JsonSerializer.deserialize(message.getBody(), AlertSendRequest.class);
command.getType());
AlertSendRequestCommand alertSendRequestCommand = JsonSerializer.deserialize( log.info("Received command : {}", alertSendRequest);
command.getBody(), AlertSendRequestCommand.class);
log.info("Received command : {}", alertSendRequestCommand); AlertSendResponse alertSendResponse = alertSenderService.syncHandler(
alertSendRequest.getGroupId(),
alertSendRequest.getTitle(),
alertSendRequest.getContent(),
alertSendRequest.getWarnType());
channel.writeAndFlush(alertSendResponse.convert2Command(message.getOpaque()));
}
AlertSendResponseCommand alertSendResponseCommand = alertSenderService.syncHandler( @Override
alertSendRequestCommand.getGroupId(), public MessageType getCommandType() {
alertSendRequestCommand.getTitle(), return MessageType.ALERT_SEND_REQUEST;
alertSendRequestCommand.getContent(),
alertSendRequestCommand.getWarnType());
channel.writeAndFlush(alertSendResponseCommand.convert2Command(command.getOpaque()));
} }
} }

20
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java

@ -33,8 +33,7 @@ import org.apache.dolphinscheduler.dao.AlertDao;
import org.apache.dolphinscheduler.dao.entity.Alert; import org.apache.dolphinscheduler.dao.entity.Alert;
import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance; import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance;
import org.apache.dolphinscheduler.dao.entity.AlertSendStatus; import org.apache.dolphinscheduler.dao.entity.AlertSendStatus;
import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponseCommand; import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponse;
import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponseResult;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
@ -166,7 +165,7 @@ public final class AlertSenderService extends Thread {
* @param content content * @param content content
* @return AlertSendResponseCommand * @return AlertSendResponseCommand
*/ */
public AlertSendResponseCommand syncHandler(int alertGroupId, String title, String content, int warnType) { public AlertSendResponse syncHandler(int alertGroupId, String title, String content, int warnType) {
List<AlertPluginInstance> alertInstanceList = alertDao.listInstanceByAlertGroupId(alertGroupId); List<AlertPluginInstance> alertInstanceList = alertDao.listInstanceByAlertGroupId(alertGroupId);
AlertData alertData = AlertData.builder() AlertData alertData = AlertData.builder()
.content(content) .content(content)
@ -175,29 +174,32 @@ public final class AlertSenderService extends Thread {
.build(); .build();
boolean sendResponseStatus = true; boolean sendResponseStatus = true;
List<AlertSendResponseResult> sendResponseResults = new ArrayList<>(); List<AlertSendResponse.AlertSendResponseResult> sendResponseResults = new ArrayList<>();
if (CollectionUtils.isEmpty(alertInstanceList)) { if (CollectionUtils.isEmpty(alertInstanceList)) {
AlertSendResponseResult alertSendResponseResult = new AlertSendResponseResult(); AlertSendResponse.AlertSendResponseResult alertSendResponseResult =
new AlertSendResponse.AlertSendResponseResult();
String message = String.format("Alert GroupId %s send error : not found alert instance", alertGroupId); String message = String.format("Alert GroupId %s send error : not found alert instance", alertGroupId);
alertSendResponseResult.setSuccess(false); alertSendResponseResult.setSuccess(false);
alertSendResponseResult.setMessage(message); alertSendResponseResult.setMessage(message);
sendResponseResults.add(alertSendResponseResult); sendResponseResults.add(alertSendResponseResult);
log.error("Alert GroupId {} send error : not found alert instance", alertGroupId); log.error("Alert GroupId {} send error : not found alert instance", alertGroupId);
return new AlertSendResponseCommand(false, sendResponseResults); return new AlertSendResponse(false, sendResponseResults);
} }
for (AlertPluginInstance instance : alertInstanceList) { for (AlertPluginInstance instance : alertInstanceList) {
AlertResult alertResult = this.alertResultHandler(instance, alertData); AlertResult alertResult = this.alertResultHandler(instance, alertData);
if (alertResult != null) { if (alertResult != null) {
AlertSendResponseResult alertSendResponseResult = new AlertSendResponseResult( AlertSendResponse.AlertSendResponseResult alertSendResponseResult =
Boolean.parseBoolean(String.valueOf(alertResult.getStatus())), alertResult.getMessage()); new AlertSendResponse.AlertSendResponseResult(
Boolean.parseBoolean(String.valueOf(alertResult.getStatus())),
alertResult.getMessage());
sendResponseStatus = sendResponseStatus && alertSendResponseResult.isSuccess(); sendResponseStatus = sendResponseStatus && alertSendResponseResult.isSuccess();
sendResponseResults.add(alertSendResponseResult); sendResponseResults.add(alertSendResponseResult);
} }
} }
return new AlertSendResponseCommand(sendResponseStatus, sendResponseResults); return new AlertSendResponse(sendResponseStatus, sendResponseResults);
} }
/** /**

32
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java

@ -22,15 +22,17 @@ 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.dao.PluginDao; import org.apache.dolphinscheduler.dao.PluginDao;
import org.apache.dolphinscheduler.remote.NettyRemotingServer; import org.apache.dolphinscheduler.remote.NettyRemotingServer;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.factory.NettyRemotingServerFactory; import org.apache.dolphinscheduler.remote.factory.NettyRemotingServerFactory;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import java.io.Closeable; import java.io.Closeable;
import java.util.List;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.boot.context.event.ApplicationReadyEvent;
@ -42,21 +44,16 @@ import org.springframework.context.event.EventListener;
@Slf4j @Slf4j
public class AlertServer implements Closeable { public class AlertServer implements Closeable {
private final PluginDao pluginDao; @Autowired
private final AlertSenderService alertSenderService; private PluginDao pluginDao;
private final AlertRequestProcessor alertRequestProcessor;
private final AlertConfig alertConfig;
private NettyRemotingServer nettyRemotingServer;
public AlertServer(PluginDao pluginDao, @Autowired
AlertSenderService alertSenderService, private AlertSenderService alertSenderService;
AlertRequestProcessor alertRequestProcessor, @Autowired
AlertConfig alertConfig) { private List<NettyRequestProcessor> nettyRequestProcessors;
this.pluginDao = pluginDao; @Autowired
this.alertSenderService = alertSenderService; private AlertConfig alertConfig;
this.alertRequestProcessor = alertRequestProcessor; private NettyRemotingServer nettyRemotingServer;
this.alertConfig = alertConfig;
}
public static void main(String[] args) { public static void main(String[] args) {
Thread.currentThread().setName(Constants.THREAD_NAME_ALERT_SERVER); Thread.currentThread().setName(Constants.THREAD_NAME_ALERT_SERVER);
@ -116,7 +113,10 @@ public class AlertServer implements Closeable {
protected void startServer() { protected void startServer() {
nettyRemotingServer = NettyRemotingServerFactory.buildNettyRemotingServer(alertConfig.getPort()); nettyRemotingServer = NettyRemotingServerFactory.buildNettyRemotingServer(alertConfig.getPort());
nettyRemotingServer.registerProcessor(CommandType.ALERT_SEND_REQUEST, alertRequestProcessor); for (NettyRequestProcessor nettyRequestProcessor : nettyRequestProcessors) {
nettyRemotingServer.registerProcessor(nettyRequestProcessor);
log.info("Success register netty processor: {}", nettyRequestProcessor.getClass().getName());
}
nettyRemotingServer.start(); nettyRemotingServer.start();
} }
} }

92
dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/AlertServerTest.java

@ -1,92 +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.alert;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.apache.dolphinscheduler.dao.PluginDao;
import org.apache.dolphinscheduler.remote.NettyRemotingServer;
import org.apache.dolphinscheduler.remote.factory.NettyRemotingServerFactory;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.Spy;
import org.mockito.junit.jupiter.MockitoExtension;
@ExtendWith(MockitoExtension.class)
public class AlertServerTest {
@Mock
private PluginDao pluginDao;
@Mock
private AlertConfig alertConfig;
@Mock
private AlertSenderService alertSenderService;
@Mock
private NettyRemotingServer nettyRemotingServer;
@InjectMocks
@Spy
private AlertServer alertServer;
@BeforeEach
void init() {
Mockito.lenient().when(pluginDao.checkPluginDefineTableExist()).thenReturn(true);
Mockito.lenient().when(alertConfig.getPort()).thenReturn(50052);
}
@Test
public void alertServerRunSuccessfully() {
doNothing().when(alertServer).checkTable();
doNothing().when(alertServer).startServer();
alertServer.run(null);
Mockito.verify(alertServer, times(1)).checkTable();
Mockito.verify(alertServer, times(1)).startServer();
Mockito.verify(alertSenderService, times(1)).start();
}
@Test
public void alertServerServerStartWithExpectedListeningPort() {
try (
MockedStatic<NettyRemotingServerFactory> mockedNettyRemotingServerFactory =
mockStatic(NettyRemotingServerFactory.class)) {
mockedNettyRemotingServerFactory.when(() -> NettyRemotingServerFactory.buildNettyRemotingServer(anyInt()))
.thenReturn(nettyRemotingServer);
alertServer.startServer();
mockedNettyRemotingServerFactory.verify(() -> NettyRemotingServerFactory.buildNettyRemotingServer(50052));
verify(nettyRemotingServer, times(1)).registerProcessor(any(), any());
verify(nettyRemotingServer, times(1)).start();
}
}
}

60
dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/processor/AlertRequestProcessorTest.java

@ -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.alert.processor;
import static org.mockito.Mockito.mock;
import org.apache.dolphinscheduler.alert.AlertRequestProcessor;
import org.apache.dolphinscheduler.alert.AlertSenderService;
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.command.alert.AlertSendRequestCommand;
import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponseCommand;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import io.netty.channel.Channel;
@ExtendWith(MockitoExtension.class)
public class AlertRequestProcessorTest {
@InjectMocks
private AlertRequestProcessor alertRequestProcessor;
@Mock
private AlertSenderService alertSenderService;
@Test
public void testProcess() {
Mockito.when(alertSenderService.syncHandler(1, "title", "content", WarningType.FAILURE.getCode()))
.thenReturn(new AlertSendResponseCommand());
Channel channel = mock(Channel.class);
AlertSendRequestCommand alertSendRequestCommand =
new AlertSendRequestCommand(1, "title", "content", WarningType.FAILURE.getCode());
Command reqCommand = alertSendRequestCommand.convert2Command();
Assertions.assertEquals(CommandType.ALERT_SEND_REQUEST, reqCommand.getType());
alertRequestProcessor.process(channel, reqCommand);
}
}

32
dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/runner/AlertSenderServiceTest.java

@ -31,7 +31,7 @@ import org.apache.dolphinscheduler.dao.PluginDao;
import org.apache.dolphinscheduler.dao.entity.Alert; import org.apache.dolphinscheduler.dao.entity.Alert;
import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance; import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance;
import org.apache.dolphinscheduler.dao.entity.PluginDefine; import org.apache.dolphinscheduler.dao.entity.PluginDefine;
import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponseCommand; import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponse;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -79,10 +79,10 @@ public class AlertSenderServiceTest {
when(alertDao.listInstanceByAlertGroupId(alertGroupId)).thenReturn(null); when(alertDao.listInstanceByAlertGroupId(alertGroupId)).thenReturn(null);
when(alertConfig.getWaitTimeout()).thenReturn(0); when(alertConfig.getWaitTimeout()).thenReturn(0);
AlertSendResponseCommand alertSendResponseCommand = AlertSendResponse alertSendResponse =
alertSenderService.syncHandler(alertGroupId, title, content, WarningType.ALL.getCode()); alertSenderService.syncHandler(alertGroupId, title, content, WarningType.ALL.getCode());
Assertions.assertFalse(alertSendResponseCommand.isSuccess()); Assertions.assertFalse(alertSendResponse.isSuccess());
alertSendResponseCommand.getResResults().forEach(result -> logger alertSendResponse.getResResults().forEach(result -> logger
.info("alert send response result, status:{}, message:{}", result.isSuccess(), result.getMessage())); .info("alert send response result, status:{}, message:{}", result.isSuccess(), result.getMessage()));
// 2.alert plugin does not exist // 2.alert plugin does not exist
@ -100,10 +100,10 @@ public class AlertSenderServiceTest {
PluginDefine pluginDefine = new PluginDefine(pluginName, "1", null); PluginDefine pluginDefine = new PluginDefine(pluginName, "1", null);
when(pluginDao.getPluginDefineById(pluginDefineId)).thenReturn(pluginDefine); when(pluginDao.getPluginDefineById(pluginDefineId)).thenReturn(pluginDefine);
alertSendResponseCommand = alertSendResponse =
alertSenderService.syncHandler(alertGroupId, title, content, WarningType.ALL.getCode()); alertSenderService.syncHandler(alertGroupId, title, content, WarningType.ALL.getCode());
Assertions.assertFalse(alertSendResponseCommand.isSuccess()); Assertions.assertFalse(alertSendResponse.isSuccess());
alertSendResponseCommand.getResResults().forEach(result -> logger alertSendResponse.getResResults().forEach(result -> logger
.info("alert send response result, status:{}, message:{}", result.isSuccess(), result.getMessage())); .info("alert send response result, status:{}, message:{}", result.isSuccess(), result.getMessage()));
// 3.alert result value is null // 3.alert result value is null
@ -112,10 +112,10 @@ public class AlertSenderServiceTest {
when(alertPluginManager.getAlertChannel(1)).thenReturn(Optional.of(alertChannelMock)); when(alertPluginManager.getAlertChannel(1)).thenReturn(Optional.of(alertChannelMock));
when(alertConfig.getWaitTimeout()).thenReturn(0); when(alertConfig.getWaitTimeout()).thenReturn(0);
alertSendResponseCommand = alertSendResponse =
alertSenderService.syncHandler(alertGroupId, title, content, WarningType.ALL.getCode()); alertSenderService.syncHandler(alertGroupId, title, content, WarningType.ALL.getCode());
Assertions.assertFalse(alertSendResponseCommand.isSuccess()); Assertions.assertFalse(alertSendResponse.isSuccess());
alertSendResponseCommand.getResResults().forEach(result -> logger alertSendResponse.getResResults().forEach(result -> logger
.info("alert send response result, status:{}, message:{}", result.isSuccess(), result.getMessage())); .info("alert send response result, status:{}, message:{}", result.isSuccess(), result.getMessage()));
// 4.abnormal information inside the alert plug-in code // 4.abnormal information inside the alert plug-in code
@ -125,10 +125,10 @@ public class AlertSenderServiceTest {
when(alertChannelMock.process(Mockito.any())).thenReturn(alertResult); when(alertChannelMock.process(Mockito.any())).thenReturn(alertResult);
when(alertPluginManager.getAlertChannel(1)).thenReturn(Optional.of(alertChannelMock)); when(alertPluginManager.getAlertChannel(1)).thenReturn(Optional.of(alertChannelMock));
alertSendResponseCommand = alertSendResponse =
alertSenderService.syncHandler(alertGroupId, title, content, WarningType.ALL.getCode()); alertSenderService.syncHandler(alertGroupId, title, content, WarningType.ALL.getCode());
Assertions.assertFalse(alertSendResponseCommand.isSuccess()); Assertions.assertFalse(alertSendResponse.isSuccess());
alertSendResponseCommand.getResResults().forEach(result -> logger alertSendResponse.getResResults().forEach(result -> logger
.info("alert send response result, status:{}, message:{}", result.isSuccess(), result.getMessage())); .info("alert send response result, status:{}, message:{}", result.isSuccess(), result.getMessage()));
// 5.alert plugin send success // 5.alert plugin send success
@ -139,10 +139,10 @@ public class AlertSenderServiceTest {
when(alertPluginManager.getAlertChannel(1)).thenReturn(Optional.of(alertChannelMock)); when(alertPluginManager.getAlertChannel(1)).thenReturn(Optional.of(alertChannelMock));
when(alertConfig.getWaitTimeout()).thenReturn(5000); when(alertConfig.getWaitTimeout()).thenReturn(5000);
alertSendResponseCommand = alertSendResponse =
alertSenderService.syncHandler(alertGroupId, title, content, WarningType.ALL.getCode()); alertSenderService.syncHandler(alertGroupId, title, content, WarningType.ALL.getCode());
Assertions.assertTrue(alertSendResponseCommand.isSuccess()); Assertions.assertTrue(alertSendResponse.isSuccess());
alertSendResponseCommand.getResResults().forEach(result -> logger alertSendResponse.getResResults().forEach(result -> logger
.info("alert send response result, status:{}, message:{}", result.isSuccess(), result.getMessage())); .info("alert send response result, status:{}, message:{}", result.isSuccess(), result.getMessage()));
} }

4
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/aspect/CacheEvictAspect.java

@ -18,7 +18,7 @@
package org.apache.dolphinscheduler.api.aspect; package org.apache.dolphinscheduler.api.aspect;
import org.apache.dolphinscheduler.common.enums.CacheType; import org.apache.dolphinscheduler.common.enums.CacheType;
import org.apache.dolphinscheduler.remote.command.CacheExpireCommand; import org.apache.dolphinscheduler.remote.command.cache.CacheExpireRequest;
import org.apache.dolphinscheduler.service.cache.CacheNotifyService; import org.apache.dolphinscheduler.service.cache.CacheNotifyService;
import org.apache.dolphinscheduler.service.cache.impl.CacheKeyGenerator; import org.apache.dolphinscheduler.service.cache.impl.CacheKeyGenerator;
@ -96,7 +96,7 @@ public class CacheEvictAspect {
} }
} }
if (StringUtils.isNotEmpty(cacheKey)) { if (StringUtils.isNotEmpty(cacheKey)) {
cacheNotifyService.notifyMaster(new CacheExpireCommand(cacheType, cacheKey).convert2Command()); cacheNotifyService.notifyMaster(new CacheExpireRequest(cacheType, cacheKey).convert2Command());
} }
} }

6
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/executor/workflow/instance/pause/pause/PauseExecuteFunction.java

@ -25,7 +25,7 @@ import org.apache.dolphinscheduler.common.enums.CommandType;
import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus; import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao; import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao;
import org.apache.dolphinscheduler.remote.command.WorkflowStateEventChangeCommand; import org.apache.dolphinscheduler.remote.command.workflow.WorkflowStateEventChangeRequest;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException; import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.remote.utils.Host;
@ -59,10 +59,10 @@ public class PauseExecuteFunction implements ExecuteFunction<PauseExecuteRequest
"The workflow instance: %s pause failed, due to update the workflow instance status in DB failed", "The workflow instance: %s pause failed, due to update the workflow instance status in DB failed",
workflowInstance.getName())); workflowInstance.getName()));
} }
WorkflowStateEventChangeCommand workflowStateEventChangeCommand = new WorkflowStateEventChangeCommand( WorkflowStateEventChangeRequest workflowStateEventChangeRequest = new WorkflowStateEventChangeRequest(
workflowInstance.getId(), 0, workflowInstance.getState(), workflowInstance.getId(), 0); workflowInstance.getId(), 0, workflowInstance.getState(), workflowInstance.getId(), 0);
try { try {
apiRpcClient.send(Host.of(workflowInstance.getHost()), workflowStateEventChangeCommand.convert2Command()); apiRpcClient.send(Host.of(workflowInstance.getHost()), workflowStateEventChangeRequest.convert2Command());
} catch (RemotingException e) { } catch (RemotingException e) {
throw new ExecuteRuntimeException( throw new ExecuteRuntimeException(
String.format( String.format(

6
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/executor/workflow/instance/stop/StopExecuteFunction.java

@ -25,7 +25,7 @@ import org.apache.dolphinscheduler.common.enums.CommandType;
import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus; import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao; import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao;
import org.apache.dolphinscheduler.remote.command.WorkflowStateEventChangeCommand; import org.apache.dolphinscheduler.remote.command.workflow.WorkflowStateEventChangeRequest;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException; import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.remote.utils.Host;
@ -61,11 +61,11 @@ public class StopExecuteFunction implements ExecuteFunction<StopRequest, StopRes
log.info("Workflow instance {} ready to stop success, will call master to stop the workflow instance", log.info("Workflow instance {} ready to stop success, will call master to stop the workflow instance",
workflowInstance.getName()); workflowInstance.getName());
// todo: Use specific stop command instead of WorkflowStateEventChangeCommand // todo: Use specific stop command instead of WorkflowStateEventChangeCommand
WorkflowStateEventChangeCommand workflowStateEventChangeCommand = new WorkflowStateEventChangeCommand( WorkflowStateEventChangeRequest workflowStateEventChangeRequest = new WorkflowStateEventChangeRequest(
workflowInstance.getId(), 0, workflowInstance.getState(), workflowInstance.getId(), 0); workflowInstance.getId(), 0, workflowInstance.getState(), workflowInstance.getId(), 0);
try { try {
apiRpcClient.send(Host.of(workflowInstance.getHost()), apiRpcClient.send(Host.of(workflowInstance.getHost()),
workflowStateEventChangeCommand.convert2Command()); workflowStateEventChangeRequest.convert2Command());
} catch (RemotingException e) { } catch (RemotingException e) {
throw new ExecuteRuntimeException( throw new ExecuteRuntimeException(
String.format("Workflow instance: %s stop failed, due to send request to master: %s failed", String.format("Workflow instance: %s stop failed, due to send request to master: %s failed",

6
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/rpc/ApiRpcClient.java

@ -18,7 +18,7 @@
package org.apache.dolphinscheduler.api.rpc; package org.apache.dolphinscheduler.api.rpc;
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.Message;
import org.apache.dolphinscheduler.remote.config.NettyClientConfig; import org.apache.dolphinscheduler.remote.config.NettyClientConfig;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException; import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.remote.utils.Host;
@ -34,8 +34,8 @@ public class ApiRpcClient {
this.nettyRemotingClient = new NettyRemotingClient(new NettyClientConfig()); this.nettyRemotingClient = new NettyRemotingClient(new NettyClientConfig());
} }
public void send(Host host, Command command) throws RemotingException { public void send(Host host, Message message) throws RemotingException {
nettyRemotingClient.send(host, command); nettyRemotingClient.send(host, message);
} }
} }

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

@ -81,10 +81,12 @@ import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.TaskGroupQueueMapper; import org.apache.dolphinscheduler.dao.mapper.TaskGroupQueueMapper;
import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao; import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao;
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
import org.apache.dolphinscheduler.remote.command.TaskExecuteStartCommand; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.WorkflowExecutingDataRequestCommand; import org.apache.dolphinscheduler.remote.command.task.TaskExecuteStartMessage;
import org.apache.dolphinscheduler.remote.command.WorkflowExecutingDataResponseCommand; import org.apache.dolphinscheduler.remote.command.task.TaskForceStartRequest;
import org.apache.dolphinscheduler.remote.command.WorkflowStateEventChangeCommand; import org.apache.dolphinscheduler.remote.command.workflow.WorkflowExecutingDataRequest;
import org.apache.dolphinscheduler.remote.command.workflow.WorkflowExecutingDataResponse;
import org.apache.dolphinscheduler.remote.command.workflow.WorkflowStateEventChangeRequest;
import org.apache.dolphinscheduler.remote.dto.WorkflowExecuteDto; import org.apache.dolphinscheduler.remote.dto.WorkflowExecuteDto;
import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService;
import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.remote.utils.Host;
@ -650,10 +652,10 @@ public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorServ
executionStatus.getDesc(), processInstance.getName()); executionStatus.getDesc(), processInstance.getName());
// directly send the process instance state change event to target master, not guarantee the event send // directly send the process instance state change event to target master, not guarantee the event send
// success // success
WorkflowStateEventChangeCommand workflowStateEventChangeCommand = new WorkflowStateEventChangeCommand( WorkflowStateEventChangeRequest workflowStateEventChangeRequest = new WorkflowStateEventChangeRequest(
processInstance.getId(), 0, processInstance.getState(), processInstance.getId(), 0); processInstance.getId(), 0, processInstance.getState(), processInstance.getId(), 0);
Host host = new Host(processInstance.getHost()); Host host = new Host(processInstance.getHost());
stateEventCallbackService.sendResult(host, workflowStateEventChangeCommand.convert2Command()); stateEventCallbackService.sendResult(host, workflowStateEventChangeRequest.convert2Command());
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
} else { } else {
log.error("Process instance state update error, processInstanceName:{}.", processInstance.getName()); log.error("Process instance state update error, processInstanceName:{}.", processInstance.getName());
@ -678,9 +680,10 @@ public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorServ
taskGroupQueue.setForceStart(Flag.YES.getCode()); taskGroupQueue.setForceStart(Flag.YES.getCode());
processService.updateTaskGroupQueue(taskGroupQueue); processService.updateTaskGroupQueue(taskGroupQueue);
log.info("Sending force start command to master."); log.info("Sending force start command to master: {}.", processInstance.getHost());
processService.sendStartTask2Master(processInstance, taskGroupQueue.getTaskId(), stateEventCallbackService.sendResult(
org.apache.dolphinscheduler.remote.command.CommandType.TASK_FORCE_STATE_EVENT_REQUEST); Host.of(processInstance.getHost()),
new TaskForceStartRequest(processInstance.getId(), taskGroupQueue.getTaskId()).convert2Command());
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; return result;
} }
@ -1148,17 +1151,17 @@ public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorServ
return null; return null;
} }
Host host = new Host(processInstance.getHost()); Host host = new Host(processInstance.getHost());
WorkflowExecutingDataRequestCommand requestCommand = new WorkflowExecutingDataRequestCommand(); WorkflowExecutingDataRequest requestCommand = new WorkflowExecutingDataRequest();
requestCommand.setProcessInstanceId(processInstanceId); requestCommand.setProcessInstanceId(processInstanceId);
org.apache.dolphinscheduler.remote.command.Command command = Message message =
stateEventCallbackService.sendSync(host, requestCommand.convert2Command()); stateEventCallbackService.sendSync(host, requestCommand.convert2Command());
if (command == null) { if (message == null) {
log.error("Query executing process instance from master error, processInstanceId:{}.", log.error("Query executing process instance from master error, processInstanceId:{}.",
processInstanceId); processInstanceId);
return null; return null;
} }
WorkflowExecutingDataResponseCommand responseCommand = WorkflowExecutingDataResponse responseCommand =
JSONUtils.parseObject(command.getBody(), WorkflowExecutingDataResponseCommand.class); JSONUtils.parseObject(message.getBody(), WorkflowExecutingDataResponse.class);
return responseCommand.getWorkflowExecuteDto(); return responseCommand.getWorkflowExecuteDto();
} }
@ -1180,20 +1183,20 @@ public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorServ
List<Server> masterServerList = monitorService.getServerListFromRegistry(true); List<Server> masterServerList = monitorService.getServerListFromRegistry(true);
Host host = new Host(masterServerList.get(0).getHost(), masterServerList.get(0).getPort()); Host host = new Host(masterServerList.get(0).getHost(), masterServerList.get(0).getPort());
TaskExecuteStartCommand taskExecuteStartCommand = new TaskExecuteStartCommand(); TaskExecuteStartMessage taskExecuteStartMessage = new TaskExecuteStartMessage();
taskExecuteStartCommand.setExecutorId(loginUser.getId()); taskExecuteStartMessage.setExecutorId(loginUser.getId());
taskExecuteStartCommand.setExecutorName(loginUser.getUserName()); taskExecuteStartMessage.setExecutorName(loginUser.getUserName());
taskExecuteStartCommand.setProjectCode(projectCode); taskExecuteStartMessage.setProjectCode(projectCode);
taskExecuteStartCommand.setTaskDefinitionCode(taskDefinitionCode); taskExecuteStartMessage.setTaskDefinitionCode(taskDefinitionCode);
taskExecuteStartCommand.setTaskDefinitionVersion(taskDefinitionVersion); taskExecuteStartMessage.setTaskDefinitionVersion(taskDefinitionVersion);
taskExecuteStartCommand.setWorkerGroup(workerGroup); taskExecuteStartMessage.setWorkerGroup(workerGroup);
taskExecuteStartCommand.setWarningGroupId(warningGroupId); taskExecuteStartMessage.setWarningGroupId(warningGroupId);
taskExecuteStartCommand.setEnvironmentCode(environmentCode); taskExecuteStartMessage.setEnvironmentCode(environmentCode);
taskExecuteStartCommand.setStartParams(startParams); taskExecuteStartMessage.setStartParams(startParams);
taskExecuteStartCommand.setDryRun(dryRun); taskExecuteStartMessage.setDryRun(dryRun);
org.apache.dolphinscheduler.remote.command.Command response = Message response =
stateEventCallbackService.sendSync(host, taskExecuteStartCommand.convert2Command()); stateEventCallbackService.sendSync(host, taskExecuteStartMessage.convert2Command());
if (response != null) { if (response != null) {
log.info("Send task execute start command complete, response is {}.", response); log.info("Send task execute start command complete, response is {}.", response);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);

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

@ -22,7 +22,7 @@ import org.apache.dolphinscheduler.api.service.MetricsCleanUpService;
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.registry.api.RegistryClient;
import org.apache.dolphinscheduler.remote.command.WorkflowMetricsCleanUpCommand; import org.apache.dolphinscheduler.remote.command.workflow.WorkflowMetricsCleanUpRequest;
import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.remote.utils.Host;
import java.util.List; import java.util.List;
@ -44,13 +44,13 @@ public class MetricsCleanUpServiceImpl implements MetricsCleanUpService {
@Override @Override
public void cleanUpWorkflowMetricsByDefinitionCode(String workflowDefinitionCode) { public void cleanUpWorkflowMetricsByDefinitionCode(String workflowDefinitionCode) {
WorkflowMetricsCleanUpCommand workflowMetricsCleanUpCommand = new WorkflowMetricsCleanUpCommand(); WorkflowMetricsCleanUpRequest workflowMetricsCleanUpRequest = new WorkflowMetricsCleanUpRequest();
workflowMetricsCleanUpCommand.setProcessDefinitionCode(workflowDefinitionCode); workflowMetricsCleanUpRequest.setProcessDefinitionCode(workflowDefinitionCode);
List<Server> masterNodeList = registryClient.getServerList(NodeType.MASTER); List<Server> masterNodeList = registryClient.getServerList(NodeType.MASTER);
for (Server server : masterNodeList) { for (Server server : masterNodeList) {
try { try {
final String host = String.format("%s:%s", server.getHost(), server.getPort()); final String host = String.format("%s:%s", server.getHost(), server.getPort());
apiRpcClient.send(Host.of(host), workflowMetricsCleanUpCommand.convert2Command()); apiRpcClient.send(Host.of(host), workflowMetricsCleanUpRequest.convert2Command());
} catch (Exception e) { } catch (Exception e) {
log.error( log.error(
"Fail to clean up workflow related metrics on {} when deleting workflow definition {}, error message {}", "Fail to clean up workflow related metrics on {} when deleting workflow definition {}, error message {}",

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

@ -44,8 +44,8 @@ import org.apache.dolphinscheduler.dao.repository.DqExecuteResultDao;
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao; import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
import org.apache.dolphinscheduler.dao.utils.TaskCacheUtils; import org.apache.dolphinscheduler.dao.utils.TaskCacheUtils;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.remote.command.TaskKillRequestCommand; import org.apache.dolphinscheduler.remote.command.task.TaskKillRequest;
import org.apache.dolphinscheduler.remote.command.TaskSavePointRequestCommand; import org.apache.dolphinscheduler.remote.command.task.TaskSavePointRequest;
import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService;
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;
@ -291,7 +291,7 @@ public class TaskInstanceServiceImpl extends BaseServiceImpl implements TaskInst
return result; return result;
} }
TaskSavePointRequestCommand command = new TaskSavePointRequestCommand(taskInstanceId); TaskSavePointRequest command = new TaskSavePointRequest(taskInstanceId);
Host host = new Host(taskInstance.getHost()); Host host = new Host(taskInstance.getHost());
stateEventCallbackService.sendResult(host, command.convert2Command()); stateEventCallbackService.sendResult(host, command.convert2Command());
@ -322,7 +322,7 @@ public class TaskInstanceServiceImpl extends BaseServiceImpl implements TaskInst
return result; return result;
} }
TaskKillRequestCommand command = new TaskKillRequestCommand(taskInstanceId); TaskKillRequest command = new TaskKillRequest(taskInstanceId);
Host host = new Host(taskInstance.getHost()); Host host = new Host(taskInstance.getHost());
stateEventCallbackService.sendResult(host, command.convert2Command()); stateEventCallbackService.sendResult(host, command.convert2Command());
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);

5
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecuteFunctionServiceTest.java

@ -65,6 +65,7 @@ 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.dao.mapper.TaskGroupQueueMapper; import org.apache.dolphinscheduler.dao.mapper.TaskGroupQueueMapper;
import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao; import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao;
import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService;
import org.apache.dolphinscheduler.service.command.CommandService; import org.apache.dolphinscheduler.service.command.CommandService;
import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.dolphinscheduler.service.process.ProcessService;
import org.apache.dolphinscheduler.service.process.TriggerRelationService; import org.apache.dolphinscheduler.service.process.TriggerRelationService;
@ -155,6 +156,9 @@ public class ExecuteFunctionServiceTest {
@Mock @Mock
private ProcessDefinitionService processDefinitionService; private ProcessDefinitionService processDefinitionService;
@Mock
private StateEventCallbackService stateEventCallbackService;
private int processDefinitionId = 1; private int processDefinitionId = 1;
private int processDefinitionVersion = 1; private int processDefinitionVersion = 1;
@ -207,6 +211,7 @@ public class ExecuteFunctionServiceTest {
processInstance.setState(WorkflowExecutionStatus.FAILURE); processInstance.setState(WorkflowExecutionStatus.FAILURE);
processInstance.setExecutorId(userId); processInstance.setExecutorId(userId);
processInstance.setTenantId(tenantId); processInstance.setTenantId(tenantId);
processInstance.setHost("127.0.0.1:5678");
processInstance.setProcessDefinitionVersion(1); processInstance.setProcessDefinitionVersion(1);
processInstance.setProcessDefinitionCode(1L); processInstance.setProcessDefinitionCode(1L);

10
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumer.java

@ -30,8 +30,8 @@ import org.apache.dolphinscheduler.dao.utils.TaskCacheUtils;
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate; import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate;
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.remote.command.Command; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.TaskDispatchCommand; import org.apache.dolphinscheduler.remote.command.task.TaskDispatchMessage;
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.ExecutorDispatcher; import org.apache.dolphinscheduler.server.master.dispatch.ExecutorDispatcher;
@ -225,7 +225,7 @@ public class TaskPriorityQueueConsumer extends BaseDaemonThread {
.taskInstance(taskInstance) .taskInstance(taskInstance)
.workerGroup(context.getWorkerGroup()) .workerGroup(context.getWorkerGroup())
.executorType(ExecutorType.WORKER) .executorType(ExecutorType.WORKER)
.command(toCommand(context)) .message(toCommand(context))
.build(); .build();
if (isTaskNeedToCheck(taskPriority)) { if (isTaskNeedToCheck(taskPriority)) {
@ -276,9 +276,9 @@ public class TaskPriorityQueueConsumer extends BaseDaemonThread {
taskEventService.addEvent(taskEvent); taskEventService.addEvent(taskEvent);
} }
private Command toCommand(TaskExecutionContext taskExecutionContext) { private Message toCommand(TaskExecutionContext taskExecutionContext) {
// todo: we didn't set the host here, since right now we didn't need to retry this message. // todo: we didn't set the host here, since right now we didn't need to retry this message.
TaskDispatchCommand requestCommand = new TaskDispatchCommand(taskExecutionContext, TaskDispatchMessage requestCommand = new TaskDispatchMessage(taskExecutionContext,
masterConfig.getMasterAddress(), masterConfig.getMasterAddress(),
taskExecutionContext.getHost(), taskExecutionContext.getHost(),
System.currentTimeMillis()); System.currentTimeMillis());

2
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutorDispatcher.java

@ -84,7 +84,7 @@ public class ExecutorDispatcher implements InitializingBean {
Host host = hostManager.select(context); Host host = hostManager.select(context);
if (StringUtils.isEmpty(host.getAddress())) { if (StringUtils.isEmpty(host.getAddress())) {
log.warn("fail to execute : {} due to no suitable worker, current task needs worker group {} to execute", log.warn("fail to execute : {} due to no suitable worker, current task needs worker group {} to execute",
context.getCommand(), context.getWorkerGroup()); context.getMessage(), context.getWorkerGroup());
throw new ExecuteException("no suitable worker"); throw new ExecuteException("no suitable worker");
} }
context.setHost(host); context.setHost(host);

12
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/context/ExecutionContext.java

@ -20,7 +20,7 @@ package org.apache.dolphinscheduler.server.master.dispatch.context;
import static org.apache.dolphinscheduler.common.constants.Constants.DEFAULT_WORKER_GROUP; import static org.apache.dolphinscheduler.common.constants.Constants.DEFAULT_WORKER_GROUP;
import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.remote.utils.Host;
import org.apache.dolphinscheduler.server.master.dispatch.enums.ExecutorType; import org.apache.dolphinscheduler.server.master.dispatch.enums.ExecutorType;
@ -43,7 +43,7 @@ public class ExecutionContext {
/** /**
* command * command
*/ */
private Command command; private Message message;
private TaskInstance taskInstance; private TaskInstance taskInstance;
@ -54,12 +54,12 @@ public class ExecutionContext {
*/ */
private String workerGroup; private String workerGroup;
public ExecutionContext(Command command, ExecutorType executorType, TaskInstance taskInstance) { public ExecutionContext(Message message, ExecutorType executorType, TaskInstance taskInstance) {
this(command, executorType, DEFAULT_WORKER_GROUP, taskInstance); this(message, executorType, DEFAULT_WORKER_GROUP, taskInstance);
} }
public ExecutionContext(Command command, ExecutorType executorType, String workerGroup, TaskInstance taskInstance) { public ExecutionContext(Message message, ExecutorType executorType, String workerGroup, TaskInstance taskInstance) {
this.command = command; this.message = message;
this.executorType = executorType; this.executorType = executorType;
this.workerGroup = workerGroup; this.workerGroup = workerGroup;
this.taskInstance = taskInstance; this.taskInstance = taskInstance;

37
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManager.java

@ -20,16 +20,14 @@ package org.apache.dolphinscheduler.server.master.dispatch.executor;
import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.constants.Constants;
import org.apache.dolphinscheduler.common.thread.ThreadUtils; import org.apache.dolphinscheduler.common.thread.ThreadUtils;
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.Message;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.config.NettyClientConfig; import org.apache.dolphinscheduler.remote.config.NettyClientConfig;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.remote.utils.Host;
import org.apache.dolphinscheduler.server.master.dispatch.context.ExecutionContext; import org.apache.dolphinscheduler.server.master.dispatch.context.ExecutionContext;
import org.apache.dolphinscheduler.server.master.dispatch.enums.ExecutorType; import org.apache.dolphinscheduler.server.master.dispatch.enums.ExecutorType;
import org.apache.dolphinscheduler.server.master.dispatch.exceptions.ExecuteException; import org.apache.dolphinscheduler.server.master.dispatch.exceptions.ExecuteException;
import org.apache.dolphinscheduler.server.master.dispatch.exceptions.WorkerGroupNotFoundException; import org.apache.dolphinscheduler.server.master.dispatch.exceptions.WorkerGroupNotFoundException;
import org.apache.dolphinscheduler.server.master.processor.TaskKillResponseProcessor;
import org.apache.dolphinscheduler.server.master.processor.TaskRecallProcessor;
import org.apache.dolphinscheduler.server.master.registry.ServerNodeManager; import org.apache.dolphinscheduler.server.master.registry.ServerNodeManager;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
@ -37,6 +35,7 @@ import org.apache.commons.collections4.CollectionUtils;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
@ -60,10 +59,7 @@ public class NettyExecutorManager extends AbstractExecutorManager<Boolean> {
private ServerNodeManager serverNodeManager; private ServerNodeManager serverNodeManager;
@Autowired @Autowired
private TaskKillResponseProcessor taskKillResponseProcessor; private List<NettyRequestProcessor> nettyRequestProcessors;
@Autowired
private TaskRecallProcessor taskRecallProcessor;
/** /**
* netty remote client * netty remote client
@ -80,8 +76,9 @@ public class NettyExecutorManager extends AbstractExecutorManager<Boolean> {
@PostConstruct @PostConstruct
public void init() { public void init() {
this.nettyRemotingClient.registerProcessor(CommandType.TASK_KILL_RESPONSE, taskKillResponseProcessor); for (NettyRequestProcessor nettyRequestProcessor : nettyRequestProcessors) {
this.nettyRemotingClient.registerProcessor(CommandType.TASK_REJECT, taskRecallProcessor); this.nettyRemotingClient.registerProcessor(nettyRequestProcessor);
}
} }
/** /**
@ -98,12 +95,12 @@ public class NettyExecutorManager extends AbstractExecutorManager<Boolean> {
// fail nodes // fail nodes
Set<String> failNodeSet = new HashSet<>(); Set<String> failNodeSet = new HashSet<>();
// build command accord executeContext // build command accord executeContext
Command command = context.getCommand(); Message message = context.getMessage();
// execute task host // execute task host
Host host = context.getHost(); Host host = context.getHost();
for (int i = 0; i < allNodes.size(); i++) { for (int i = 0; i < allNodes.size(); i++) {
try { try {
doExecute(host, command); doExecute(host, message);
context.setHost(host); context.setHost(host);
// We set the host to taskInstance to avoid when the worker down, this taskInstance may not be // We set the host to taskInstance to avoid when the worker down, this taskInstance may not be
// failovered, due to the taskInstance's host // failovered, due to the taskInstance's host
@ -111,14 +108,14 @@ public class NettyExecutorManager extends AbstractExecutorManager<Boolean> {
context.getTaskInstance().setHost(host.getAddress()); context.getTaskInstance().setHost(host.getAddress());
return; return;
} catch (ExecuteException ex) { } catch (ExecuteException ex) {
log.error("Execute command {} error", command, ex); log.error("Execute command {} error", message, ex);
try { try {
failNodeSet.add(host.getAddress()); failNodeSet.add(host.getAddress());
Set<String> tmpAllIps = new HashSet<>(allNodes); Set<String> tmpAllIps = new HashSet<>(allNodes);
Collection<String> remained = CollectionUtils.subtract(tmpAllIps, failNodeSet); Collection<String> remained = CollectionUtils.subtract(tmpAllIps, failNodeSet);
if (CollectionUtils.isNotEmpty(remained)) { if (CollectionUtils.isNotEmpty(remained)) {
host = Host.of(remained.iterator().next()); host = Host.of(remained.iterator().next());
log.error("retry execute command : {} host : {}", command, host); log.error("retry execute command : {} host : {}", message, host);
} else { } else {
throw new ExecuteException("fail after try all nodes"); throw new ExecuteException("fail after try all nodes");
} }
@ -132,33 +129,33 @@ public class NettyExecutorManager extends AbstractExecutorManager<Boolean> {
@Override @Override
public void executeDirectly(ExecutionContext context) throws ExecuteException { public void executeDirectly(ExecutionContext context) throws ExecuteException {
Host host = context.getHost(); Host host = context.getHost();
doExecute(host, context.getCommand()); doExecute(host, context.getMessage());
} }
/** /**
* execute logic * execute logic
* *
* @param host host * @param host host
* @param command command * @param message command
* @throws ExecuteException if error throws ExecuteException * @throws ExecuteException if error throws ExecuteException
*/ */
public void doExecute(final Host host, final Command command) throws ExecuteException { public void doExecute(final Host host, final Message message) throws ExecuteException {
// retry count,default retry 3 // retry count,default retry 3
int retryCount = 3; int retryCount = 3;
boolean success = false; boolean success = false;
do { do {
try { try {
nettyRemotingClient.send(host, command); nettyRemotingClient.send(host, message);
success = true; success = true;
} catch (Exception ex) { } catch (Exception ex) {
log.error("Send command to {} error, command: {}", host, command, ex); log.error("Send command to {} error, command: {}", host, message, ex);
retryCount--; retryCount--;
ThreadUtils.sleep(Constants.SLEEP_TIME_MILLIS); ThreadUtils.sleep(Constants.SLEEP_TIME_MILLIS);
} }
} while (retryCount >= 0 && !success); } while (retryCount >= 0 && !success);
if (!success) { if (!success) {
throw new ExecuteException(String.format("send command : %s to %s error", command, host)); throw new ExecuteException(String.format("send command : %s to %s error", message, host));
} }
} }

20
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskDelayEventHandler.java

@ -22,12 +22,12 @@ import org.apache.dolphinscheduler.common.enums.TaskEventType;
import org.apache.dolphinscheduler.dao.entity.TaskInstance; 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.dao.utils.TaskInstanceUtils; import org.apache.dolphinscheduler.dao.utils.TaskInstanceUtils;
import org.apache.dolphinscheduler.remote.command.TaskExecuteRunningAckMessage; import org.apache.dolphinscheduler.remote.command.task.TaskExecuteRunningMessageAck;
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.processor.queue.TaskEvent; import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable; import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable;
import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThreadPool; import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThreadPool;
import org.apache.dolphinscheduler.service.process.ProcessService;
import java.util.Optional; import java.util.Optional;
@ -43,15 +43,15 @@ public class TaskDelayEventHandler implements TaskEventHandler {
@Autowired @Autowired
private ProcessInstanceExecCacheManager processInstanceExecCacheManager; private ProcessInstanceExecCacheManager processInstanceExecCacheManager;
@Autowired
private ProcessService processService;
@Autowired @Autowired
private TaskInstanceDao taskInstanceDao; private TaskInstanceDao taskInstanceDao;
@Autowired @Autowired
private WorkflowExecuteThreadPool workflowExecuteThreadPool; private WorkflowExecuteThreadPool workflowExecuteThreadPool;
@Autowired
private MasterConfig masterConfig;
@Override @Override
public void handleTaskEvent(TaskEvent taskEvent) throws TaskEventHandleError { public void handleTaskEvent(TaskEvent taskEvent) throws TaskEventHandleError {
int taskInstanceId = taskEvent.getTaskInstanceId(); int taskInstanceId = taskEvent.getTaskInstanceId();
@ -111,9 +111,13 @@ public class TaskDelayEventHandler implements TaskEventHandler {
private void sendAckToWorker(TaskEvent taskEvent) { private void sendAckToWorker(TaskEvent taskEvent) {
// If event handle success, send ack to worker to otherwise the worker will retry this event // If event handle success, send ack to worker to otherwise the worker will retry this event
TaskExecuteRunningAckMessage taskExecuteRunningAckMessage = TaskExecuteRunningMessageAck taskExecuteRunningMessageAck =
new TaskExecuteRunningAckMessage(true, taskEvent.getTaskInstanceId()); new TaskExecuteRunningMessageAck(true,
taskEvent.getChannel().writeAndFlush(taskExecuteRunningAckMessage.convert2Command()); taskEvent.getTaskInstanceId(),
masterConfig.getMasterAddress(),
taskEvent.getWorkerAddress(),
System.currentTimeMillis());
taskEvent.getChannel().writeAndFlush(taskExecuteRunningMessageAck.convert2Command());
} }
@Override @Override

6
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskRejectByWorkerEventHandler.java

@ -19,7 +19,7 @@ package org.apache.dolphinscheduler.server.master.event;
import org.apache.dolphinscheduler.common.enums.TaskEventType; import org.apache.dolphinscheduler.common.enums.TaskEventType;
import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.remote.command.TaskRejectAckCommand; import org.apache.dolphinscheduler.remote.command.task.TaskRejectMessageAck;
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.processor.queue.TaskEvent; import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
@ -69,12 +69,12 @@ public class TaskRejectByWorkerEventHandler implements TaskEventHandler {
} }
public void sendAckToWorker(TaskEvent taskEvent) { public void sendAckToWorker(TaskEvent taskEvent) {
TaskRejectAckCommand taskRejectAckMessage = new TaskRejectAckCommand(true, TaskRejectMessageAck taskRejectMessageAck = new TaskRejectMessageAck(true,
taskEvent.getTaskInstanceId(), taskEvent.getTaskInstanceId(),
masterConfig.getMasterAddress(), masterConfig.getMasterAddress(),
taskEvent.getWorkerAddress(), taskEvent.getWorkerAddress(),
System.currentTimeMillis()); System.currentTimeMillis());
taskEvent.getChannel().writeAndFlush(taskRejectAckMessage.convert2Command()); taskEvent.getChannel().writeAndFlush(taskRejectMessageAck.convert2Command());
} }
@Override @Override

4
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskResultEventHandler.java

@ -22,7 +22,7 @@ import org.apache.dolphinscheduler.common.enums.TaskEventType;
import org.apache.dolphinscheduler.dao.entity.TaskInstance; 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.dao.utils.TaskInstanceUtils; import org.apache.dolphinscheduler.dao.utils.TaskInstanceUtils;
import org.apache.dolphinscheduler.remote.command.TaskExecuteAckCommand; import org.apache.dolphinscheduler.remote.command.task.TaskExecuteResultMessageAck;
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.processor.queue.TaskEvent; import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
@ -120,7 +120,7 @@ public class TaskResultEventHandler implements TaskEventHandler {
return; return;
} }
// we didn't set the receiver address, since the ack doen's need to retry // we didn't set the receiver address, since the ack doen's need to retry
TaskExecuteAckCommand taskExecuteAckMessage = new TaskExecuteAckCommand(true, TaskExecuteResultMessageAck taskExecuteAckMessage = new TaskExecuteResultMessageAck(true,
taskEvent.getTaskInstanceId(), taskEvent.getTaskInstanceId(),
masterConfig.getMasterAddress(), masterConfig.getMasterAddress(),
taskEvent.getWorkerAddress(), taskEvent.getWorkerAddress(),

17
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskRunningEventHandler.java

@ -22,8 +22,9 @@ import org.apache.dolphinscheduler.common.enums.TaskEventType;
import org.apache.dolphinscheduler.dao.entity.TaskInstance; 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.dao.utils.TaskInstanceUtils; import org.apache.dolphinscheduler.dao.utils.TaskInstanceUtils;
import org.apache.dolphinscheduler.remote.command.TaskExecuteRunningAckMessage; import org.apache.dolphinscheduler.remote.command.task.TaskExecuteRunningMessageAck;
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.processor.queue.TaskEvent; import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable; import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable;
import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThreadPool; import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThreadPool;
@ -45,6 +46,9 @@ public class TaskRunningEventHandler implements TaskEventHandler {
@Autowired @Autowired
private TaskInstanceDao taskInstanceDao; private TaskInstanceDao taskInstanceDao;
@Autowired
private MasterConfig masterConfig;
@Override @Override
public void handleTaskEvent(TaskEvent taskEvent) throws TaskEventHandleError { public void handleTaskEvent(TaskEvent taskEvent) throws TaskEventHandleError {
int taskInstanceId = taskEvent.getTaskInstanceId(); int taskInstanceId = taskEvent.getTaskInstanceId();
@ -103,9 +107,14 @@ public class TaskRunningEventHandler implements TaskEventHandler {
private void sendAckToWorker(TaskEvent taskEvent) { private void sendAckToWorker(TaskEvent taskEvent) {
// If event handle success, send ack to worker to otherwise the worker will retry this event // If event handle success, send ack to worker to otherwise the worker will retry this event
TaskExecuteRunningAckMessage taskExecuteRunningAckMessage = TaskExecuteRunningMessageAck taskExecuteRunningMessageAck =
new TaskExecuteRunningAckMessage(true, taskEvent.getTaskInstanceId()); new TaskExecuteRunningMessageAck(
taskEvent.getChannel().writeAndFlush(taskExecuteRunningAckMessage.convert2Command()); true,
taskEvent.getTaskInstanceId(),
masterConfig.getMasterAddress(),
taskEvent.getWorkerAddress(),
System.currentTimeMillis());
taskEvent.getChannel().writeAndFlush(taskExecuteRunningMessageAck.convert2Command());
} }
@Override @Override

5
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskStateEventHandler.java

@ -19,6 +19,7 @@ package org.apache.dolphinscheduler.server.master.event;
import org.apache.dolphinscheduler.common.enums.StateEventType; import org.apache.dolphinscheduler.common.enums.StateEventType;
import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
import org.apache.dolphinscheduler.server.master.metrics.TaskMetrics; import org.apache.dolphinscheduler.server.master.metrics.TaskMetrics;
import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable; import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable;
import org.apache.dolphinscheduler.server.master.runner.task.ITaskProcessor; import org.apache.dolphinscheduler.server.master.runner.task.ITaskProcessor;
@ -76,7 +77,11 @@ public class TaskStateEventHandler implements StateEventHandler {
workflowExecuteRunnable.taskFinished(task); workflowExecuteRunnable.taskFinished(task);
if (task.getTaskGroupId() > 0) { if (task.getTaskGroupId() > 0) {
log.info("The task instance need to release task Group: {}", task.getTaskGroupId()); log.info("The task instance need to release task Group: {}", task.getTaskGroupId());
try {
workflowExecuteRunnable.releaseTaskGroup(task); workflowExecuteRunnable.releaseTaskGroup(task);
} catch (RemotingException | InterruptedException e) {
throw new StateEventHandleException("Release task group failed", e);
}
} }
return true; return true;
} }

2
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskUpdatePidEventHandler.java

@ -21,7 +21,7 @@ import org.apache.dolphinscheduler.common.enums.TaskEventType;
import org.apache.dolphinscheduler.dao.entity.TaskInstance; 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.dao.utils.TaskInstanceUtils; import org.apache.dolphinscheduler.dao.utils.TaskInstanceUtils;
import org.apache.dolphinscheduler.remote.command.TaskUpdatePidAckMessage; import org.apache.dolphinscheduler.remote.command.task.TaskUpdatePidAckMessage;
import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager; import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent; import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable; import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable;

31
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/CacheProcessor.java

@ -19,9 +19,9 @@ package org.apache.dolphinscheduler.server.master.processor;
import org.apache.dolphinscheduler.common.enums.CacheType; import org.apache.dolphinscheduler.common.enums.CacheType;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.remote.command.CacheExpireCommand; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.cache.CacheExpireRequest;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -31,7 +31,6 @@ import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel; import io.netty.channel.Channel;
/** /**
@ -45,28 +44,30 @@ public class CacheProcessor implements NettyRequestProcessor {
private CacheManager cacheManager; private CacheManager cacheManager;
@Override @Override
public void process(Channel channel, Command command) { public void process(Channel channel, Message message) {
Preconditions.checkArgument(CommandType.CACHE_EXPIRE == command.getType(), CacheExpireRequest cacheExpireRequest = JSONUtils.parseObject(message.getBody(), CacheExpireRequest.class);
String.format("invalid command type: %s", command.getType()));
CacheExpireCommand cacheExpireCommand = JSONUtils.parseObject(command.getBody(), CacheExpireCommand.class); log.info("received command : {}", cacheExpireRequest);
log.info("received command : {}", cacheExpireCommand); this.cacheExpire(cacheExpireRequest);
}
this.cacheExpire(cacheExpireCommand); @Override
public MessageType getCommandType() {
return MessageType.CACHE_EXPIRE;
} }
private void cacheExpire(CacheExpireCommand cacheExpireCommand) { private void cacheExpire(CacheExpireRequest cacheExpireRequest) {
if (cacheExpireCommand.getCacheKey().isEmpty()) { if (cacheExpireRequest.getCacheKey().isEmpty()) {
return; return;
} }
CacheType cacheType = cacheExpireCommand.getCacheType(); CacheType cacheType = cacheExpireRequest.getCacheType();
Cache cache = cacheManager.getCache(cacheType.getCacheName()); Cache cache = cacheManager.getCache(cacheType.getCacheName());
if (cache != null) { if (cache != null) {
cache.evict(cacheExpireCommand.getCacheKey()); cache.evict(cacheExpireRequest.getCacheKey());
log.info("cache evict, type:{}, key:{}", cacheType.getCacheName(), cacheExpireCommand.getCacheKey()); log.info("cache evict, type:{}, key:{}", cacheType.getCacheName(), cacheExpireRequest.getCacheKey());
} }
} }
} }

45
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/StateEventProcessor.java

@ -21,9 +21,9 @@ import org.apache.dolphinscheduler.common.enums.StateEventType;
import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus; import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils; import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.WorkflowStateEventChangeCommand; import org.apache.dolphinscheduler.remote.command.workflow.WorkflowStateEventChangeRequest;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.event.StateEvent; import org.apache.dolphinscheduler.server.master.event.StateEvent;
import org.apache.dolphinscheduler.server.master.event.TaskStateEvent; import org.apache.dolphinscheduler.server.master.event.TaskStateEvent;
@ -35,7 +35,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel; import io.netty.channel.Channel;
/** /**
@ -49,17 +48,14 @@ public class StateEventProcessor implements NettyRequestProcessor {
private StateEventResponseService stateEventResponseService; private StateEventResponseService stateEventResponseService;
@Override @Override
public void process(Channel channel, Command command) { public void process(Channel channel, Message message) {
Preconditions.checkArgument(CommandType.STATE_EVENT_REQUEST == command.getType(), WorkflowStateEventChangeRequest workflowStateEventChangeRequest =
String.format("invalid command type: %s", command.getType())); JSONUtils.parseObject(message.getBody(), WorkflowStateEventChangeRequest.class);
WorkflowStateEventChangeCommand workflowStateEventChangeCommand =
JSONUtils.parseObject(command.getBody(), WorkflowStateEventChangeCommand.class);
StateEvent stateEvent; StateEvent stateEvent;
if (workflowStateEventChangeCommand.getDestTaskInstanceId() == 0) { if (workflowStateEventChangeRequest.getDestTaskInstanceId() == 0) {
stateEvent = createWorkflowStateEvent(workflowStateEventChangeCommand); stateEvent = createWorkflowStateEvent(workflowStateEventChangeRequest);
} else { } else {
stateEvent = createTaskStateEvent(workflowStateEventChangeCommand); stateEvent = createTaskStateEvent(workflowStateEventChangeRequest);
} }
try ( try (
@ -71,26 +67,31 @@ public class StateEventProcessor implements NettyRequestProcessor {
} }
private TaskStateEvent createTaskStateEvent(WorkflowStateEventChangeCommand workflowStateEventChangeCommand) { @Override
public MessageType getCommandType() {
return MessageType.STATE_EVENT_REQUEST;
}
private TaskStateEvent createTaskStateEvent(WorkflowStateEventChangeRequest workflowStateEventChangeRequest) {
return TaskStateEvent.builder() return TaskStateEvent.builder()
.processInstanceId(workflowStateEventChangeCommand.getDestProcessInstanceId()) .processInstanceId(workflowStateEventChangeRequest.getDestProcessInstanceId())
.taskInstanceId(workflowStateEventChangeCommand.getDestTaskInstanceId()) .taskInstanceId(workflowStateEventChangeRequest.getDestTaskInstanceId())
.type(StateEventType.TASK_STATE_CHANGE) .type(StateEventType.TASK_STATE_CHANGE)
.key(workflowStateEventChangeCommand.getKey()) .key(workflowStateEventChangeRequest.getKey())
.build(); .build();
} }
private WorkflowStateEvent createWorkflowStateEvent(WorkflowStateEventChangeCommand workflowStateEventChangeCommand) { private WorkflowStateEvent createWorkflowStateEvent(WorkflowStateEventChangeRequest workflowStateEventChangeRequest) {
WorkflowExecutionStatus workflowExecutionStatus = workflowStateEventChangeCommand.getSourceStatus(); WorkflowExecutionStatus workflowExecutionStatus = workflowStateEventChangeRequest.getSourceStatus();
if (workflowStateEventChangeCommand.getSourceProcessInstanceId() != workflowStateEventChangeCommand if (workflowStateEventChangeRequest.getSourceProcessInstanceId() != workflowStateEventChangeRequest
.getDestProcessInstanceId()) { .getDestProcessInstanceId()) {
workflowExecutionStatus = WorkflowExecutionStatus.RUNNING_EXECUTION; workflowExecutionStatus = WorkflowExecutionStatus.RUNNING_EXECUTION;
} }
return WorkflowStateEvent.builder() return WorkflowStateEvent.builder()
.processInstanceId(workflowStateEventChangeCommand.getDestProcessInstanceId()) .processInstanceId(workflowStateEventChangeRequest.getDestProcessInstanceId())
.type(StateEventType.PROCESS_STATE_CHANGE) .type(StateEventType.PROCESS_STATE_CHANGE)
.status(workflowExecutionStatus) .status(workflowExecutionStatus)
.key(workflowStateEventChangeCommand.getKey()) .key(workflowStateEventChangeRequest.getKey())
.build(); .build();
} }

25
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskExecuteResponseProcessor.java → dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskExecuteResultProcessor.java

@ -19,9 +19,9 @@ package org.apache.dolphinscheduler.server.master.processor;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils; import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.TaskExecuteResultCommand; import org.apache.dolphinscheduler.remote.command.task.TaskExecuteResultMessage;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent; import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEventService; import org.apache.dolphinscheduler.server.master.processor.queue.TaskEventService;
@ -31,7 +31,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel; import io.netty.channel.Channel;
/** /**
@ -39,7 +38,7 @@ import io.netty.channel.Channel;
*/ */
@Component @Component
@Slf4j @Slf4j
public class TaskExecuteResponseProcessor implements NettyRequestProcessor { public class TaskExecuteResultProcessor implements NettyRequestProcessor {
@Autowired @Autowired
private TaskEventService taskEventService; private TaskEventService taskEventService;
@ -49,15 +48,12 @@ public class TaskExecuteResponseProcessor implements NettyRequestProcessor {
* need master process , state persistence * need master process , state persistence
* *
* @param channel channel * @param channel channel
* @param command command * @param message command
*/ */
@Override @Override
public void process(Channel channel, Command command) { public void process(Channel channel, Message message) {
Preconditions.checkArgument(CommandType.TASK_EXECUTE_RESULT == command.getType(), TaskExecuteResultMessage taskExecuteResultMessage = JSONUtils.parseObject(message.getBody(),
String.format("invalid command type : %s", command.getType())); TaskExecuteResultMessage.class);
TaskExecuteResultCommand taskExecuteResultMessage = JSONUtils.parseObject(command.getBody(),
TaskExecuteResultCommand.class);
TaskEvent taskResultEvent = TaskEvent.newResultEvent(taskExecuteResultMessage, TaskEvent taskResultEvent = TaskEvent.newResultEvent(taskExecuteResultMessage,
channel, channel,
taskExecuteResultMessage.getMessageSenderAddress()); taskExecuteResultMessage.getMessageSenderAddress());
@ -69,4 +65,9 @@ public class TaskExecuteResponseProcessor implements NettyRequestProcessor {
taskEventService.addEvent(taskResultEvent); taskEventService.addEvent(taskResultEvent);
} }
} }
@Override
public MessageType getCommandType() {
return MessageType.TASK_EXECUTE_RESULT_MESSAGE;
}
} }

22
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskExecuteRunningProcessor.java

@ -18,9 +18,9 @@
package org.apache.dolphinscheduler.server.master.processor; package org.apache.dolphinscheduler.server.master.processor;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.TaskExecuteRunningCommand; import org.apache.dolphinscheduler.remote.command.task.TaskExecuteRunningMessage;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent; import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEventService; import org.apache.dolphinscheduler.server.master.processor.queue.TaskEventService;
@ -30,7 +30,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel; import io.netty.channel.Channel;
/** /**
@ -47,14 +46,12 @@ public class TaskExecuteRunningProcessor implements NettyRequestProcessor {
* task ack process * task ack process
* *
* @param channel channel channel * @param channel channel channel
* @param command command TaskExecuteAckCommand * @param message command TaskExecuteAckCommand
*/ */
@Override @Override
public void process(Channel channel, Command command) { public void process(Channel channel, Message message) {
Preconditions.checkArgument(CommandType.TASK_EXECUTE_RUNNING == command.getType(), TaskExecuteRunningMessage taskExecuteRunningMessage =
String.format("invalid command type : %s", command.getType())); JSONUtils.parseObject(message.getBody(), TaskExecuteRunningMessage.class);
TaskExecuteRunningCommand taskExecuteRunningMessage =
JSONUtils.parseObject(command.getBody(), TaskExecuteRunningCommand.class);
log.info("taskExecuteRunningCommand: {}", taskExecuteRunningMessage); log.info("taskExecuteRunningCommand: {}", taskExecuteRunningMessage);
TaskEvent taskEvent = TaskEvent.newRunningEvent(taskExecuteRunningMessage, TaskEvent taskEvent = TaskEvent.newRunningEvent(taskExecuteRunningMessage,
@ -63,4 +60,9 @@ public class TaskExecuteRunningProcessor implements NettyRequestProcessor {
taskEventService.addEvent(taskEvent); taskEventService.addEvent(taskEvent);
} }
@Override
public MessageType getCommandType() {
return MessageType.TASK_EXECUTE_RUNNING_MESSAGE;
}
} }

34
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskExecuteStartProcessor.java

@ -20,9 +20,9 @@ package org.apache.dolphinscheduler.server.master.processor;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionDao; import org.apache.dolphinscheduler.dao.repository.TaskDefinitionDao;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.TaskExecuteStartCommand; import org.apache.dolphinscheduler.remote.command.task.TaskExecuteStartMessage;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.runner.StreamTaskExecuteRunnable; import org.apache.dolphinscheduler.server.master.runner.StreamTaskExecuteRunnable;
import org.apache.dolphinscheduler.server.master.runner.StreamTaskExecuteThreadPool; import org.apache.dolphinscheduler.server.master.runner.StreamTaskExecuteThreadPool;
@ -32,7 +32,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel; import io.netty.channel.Channel;
/** /**
@ -49,28 +48,31 @@ public class TaskExecuteStartProcessor implements NettyRequestProcessor {
private TaskDefinitionDao taskDefinitionDao; private TaskDefinitionDao taskDefinitionDao;
@Override @Override
public void process(Channel channel, Command command) { public void process(Channel channel, Message message) {
Preconditions.checkArgument(CommandType.TASK_EXECUTE_START == command.getType(), TaskExecuteStartMessage taskExecuteStartMessage =
String.format("invalid command type : %s", command.getType())); JSONUtils.parseObject(message.getBody(), TaskExecuteStartMessage.class);
TaskExecuteStartCommand taskExecuteStartCommand = log.info("taskExecuteStartCommand: {}", taskExecuteStartMessage);
JSONUtils.parseObject(command.getBody(), TaskExecuteStartCommand.class);
log.info("taskExecuteStartCommand: {}", taskExecuteStartCommand);
TaskDefinition taskDefinition = taskDefinitionDao.findTaskDefinition( TaskDefinition taskDefinition = taskDefinitionDao.findTaskDefinition(
taskExecuteStartCommand.getTaskDefinitionCode(), taskExecuteStartCommand.getTaskDefinitionVersion()); taskExecuteStartMessage.getTaskDefinitionCode(), taskExecuteStartMessage.getTaskDefinitionVersion());
if (taskDefinition == null) { if (taskDefinition == null) {
log.error("Task definition can not be found, taskDefinitionCode:{}, taskDefinitionVersion:{}", log.error("Task definition can not be found, taskDefinitionCode:{}, taskDefinitionVersion:{}",
taskExecuteStartCommand.getTaskDefinitionCode(), taskExecuteStartMessage.getTaskDefinitionCode(),
taskExecuteStartCommand.getTaskDefinitionVersion()); taskExecuteStartMessage.getTaskDefinitionVersion());
return; return;
} }
streamTaskExecuteThreadPool.execute(new StreamTaskExecuteRunnable(taskDefinition, taskExecuteStartCommand)); streamTaskExecuteThreadPool.execute(new StreamTaskExecuteRunnable(taskDefinition, taskExecuteStartMessage));
// response // response
Command response = new Command(command.getOpaque()); Message response = new Message(message.getOpaque());
response.setType(CommandType.TASK_EXECUTE_START); response.setType(MessageType.TASK_EXECUTE_START);
response.setBody(new byte[0]); response.setBody(new byte[0]);
channel.writeAndFlush(response); channel.writeAndFlush(response);
} }
@Override
public MessageType getCommandType() {
return MessageType.TASK_EXECUTE_START;
}
} }

66
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskForceStartProcessor.java

@ -0,0 +1,66 @@
/*
* 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.processor;
import org.apache.dolphinscheduler.common.enums.StateEventType;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.task.TaskForceStartRequest;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.event.TaskStateEvent;
import org.apache.dolphinscheduler.server.master.processor.queue.StateEventResponseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import io.netty.channel.Channel;
@Component
@Slf4j
public class TaskForceStartProcessor implements NettyRequestProcessor {
@Autowired
private StateEventResponseService stateEventResponseService;
@Override
public void process(Channel channel, Message message) {
TaskForceStartRequest taskEventChangeCommand =
JSONUtils.parseObject(message.getBody(), TaskForceStartRequest.class);
TaskStateEvent stateEvent = TaskStateEvent.builder()
.processInstanceId(taskEventChangeCommand.getProcessInstanceId())
.taskInstanceId(taskEventChangeCommand.getTaskInstanceId())
.key(taskEventChangeCommand.getKey())
.type(StateEventType.WAKE_UP_TASK_GROUP)
.build();
try (
LogUtils.MDCAutoClosableContext mdcAutoClosableContext = LogUtils.setWorkflowAndTaskInstanceIDMDC(
stateEvent.getProcessInstanceId(), stateEvent.getTaskInstanceId())) {
log.info("Received task event change command, event: {}", stateEvent);
stateEventResponseService.addEvent2WorkflowExecute(stateEvent);
}
}
@Override
public MessageType getCommandType() {
return MessageType.TASK_FORCE_STATE_EVENT_REQUEST;
}
}

22
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskKillResponseProcessor.java

@ -18,16 +18,15 @@
package org.apache.dolphinscheduler.server.master.processor; package org.apache.dolphinscheduler.server.master.processor;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.TaskKillResponseCommand; import org.apache.dolphinscheduler.remote.command.task.TaskKillResponse;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel; import io.netty.channel.Channel;
/** /**
@ -42,17 +41,18 @@ public class TaskKillResponseProcessor implements NettyRequestProcessor {
* need master process , state persistence * need master process , state persistence
* *
* @param channel channel * @param channel channel
* @param command command * @param message command
*/ */
@Override @Override
public void process(Channel channel, Command command) { public void process(Channel channel, Message message) {
Preconditions.checkArgument(CommandType.TASK_KILL_RESPONSE == command.getType(), TaskKillResponse responseCommand = JSONUtils.parseObject(message.getBody(), TaskKillResponse.class);
String.format("invalid command type : %s", command.getType()));
TaskKillResponseCommand responseCommand =
JSONUtils.parseObject(command.getBody(), TaskKillResponseCommand.class);
log.info("[TaskInstance-{}] Received task kill response command : {}", log.info("[TaskInstance-{}] Received task kill response command : {}",
responseCommand.getTaskInstanceId(), responseCommand); responseCommand.getTaskInstanceId(), responseCommand);
} }
@Override
public MessageType getCommandType() {
return MessageType.TASK_KILL_RESPONSE;
}
} }

20
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskRecallProcessor.java

@ -19,9 +19,9 @@ package org.apache.dolphinscheduler.server.master.processor;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils; import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.TaskRejectCommand; import org.apache.dolphinscheduler.remote.command.task.TaskRejectMessage;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent; import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEventService; import org.apache.dolphinscheduler.server.master.processor.queue.TaskEventService;
@ -31,7 +31,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel; import io.netty.channel.Channel;
/** /**
@ -48,13 +47,11 @@ public class TaskRecallProcessor implements NettyRequestProcessor {
* task ack process * task ack process
* *
* @param channel channel channel * @param channel channel channel
* @param command command TaskExecuteAckCommand * @param message command TaskExecuteAckCommand
*/ */
@Override @Override
public void process(Channel channel, Command command) { public void process(Channel channel, Message message) {
Preconditions.checkArgument(CommandType.TASK_REJECT == command.getType(), TaskRejectMessage recallCommand = JSONUtils.parseObject(message.getBody(), TaskRejectMessage.class);
String.format("invalid command type : %s", command.getType()));
TaskRejectCommand recallCommand = JSONUtils.parseObject(command.getBody(), TaskRejectCommand.class);
TaskEvent taskEvent = TaskEvent.newRecallEvent(recallCommand, channel); TaskEvent taskEvent = TaskEvent.newRecallEvent(recallCommand, channel);
try ( try (
final LogUtils.MDCAutoClosableContext mdcAutoClosableContext = LogUtils.setWorkflowAndTaskInstanceIDMDC( final LogUtils.MDCAutoClosableContext mdcAutoClosableContext = LogUtils.setWorkflowAndTaskInstanceIDMDC(
@ -63,4 +60,9 @@ public class TaskRecallProcessor implements NettyRequestProcessor {
taskEventService.addEvent(taskEvent); taskEventService.addEvent(taskEvent);
} }
} }
@Override
public MessageType getCommandType() {
return MessageType.TASK_REJECT;
}
} }

28
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskUpdatePidProcessor.java

@ -18,9 +18,9 @@
package org.apache.dolphinscheduler.server.master.processor; package org.apache.dolphinscheduler.server.master.processor;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.TaskUpdatePidCommand; import org.apache.dolphinscheduler.remote.command.task.TaskUpdatePidMessage;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent; import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEventService; import org.apache.dolphinscheduler.server.master.processor.queue.TaskEventService;
@ -30,7 +30,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel; import io.netty.channel.Channel;
/** /**
@ -47,20 +46,23 @@ public class TaskUpdatePidProcessor implements NettyRequestProcessor {
* task ack process * task ack process
* *
* @param channel channel channel * @param channel channel channel
* @param command command TaskExecuteAckCommand * @param message command TaskExecuteAckCommand
*/ */
@Override @Override
public void process(Channel channel, Command command) { public void process(Channel channel, Message message) {
Preconditions.checkArgument(CommandType.TASK_UPDATE_PID == command.getType(), TaskUpdatePidMessage taskUpdatePidRequest =
String.format("invalid command type : %s", command.getType())); JSONUtils.parseObject(message.getBody(), TaskUpdatePidMessage.class);
TaskUpdatePidCommand taskUpdatePidCommand = log.info("taskUpdatePidCommand: {}", taskUpdatePidRequest);
JSONUtils.parseObject(command.getBody(), TaskUpdatePidCommand.class);
log.info("taskUpdatePidCommand: {}", taskUpdatePidCommand);
TaskEvent taskEvent = TaskEvent.newUpdatePidEvent(taskUpdatePidCommand, TaskEvent taskEvent = TaskEvent.newUpdatePidEvent(taskUpdatePidRequest,
channel, channel,
taskUpdatePidCommand.getMessageSenderAddress()); taskUpdatePidRequest.getMessageSenderAddress());
taskEventService.addEvent(taskEvent); taskEventService.addEvent(taskEvent);
} }
@Override
public MessageType getCommandType() {
return MessageType.TASK_UPDATE_PID_MESSAGE;
}
} }

24
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskEventProcessor.java → dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskWakeupProcessor.java

@ -20,9 +20,9 @@ package org.apache.dolphinscheduler.server.master.processor;
import org.apache.dolphinscheduler.common.enums.StateEventType; import org.apache.dolphinscheduler.common.enums.StateEventType;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils; import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.TaskEventChangeCommand; import org.apache.dolphinscheduler.remote.command.task.TaskWakeupRequest;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.event.TaskStateEvent; import org.apache.dolphinscheduler.server.master.event.TaskStateEvent;
import org.apache.dolphinscheduler.server.master.processor.queue.StateEventResponseService; import org.apache.dolphinscheduler.server.master.processor.queue.StateEventResponseService;
@ -32,7 +32,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel; import io.netty.channel.Channel;
/** /**
@ -40,19 +39,15 @@ import io.netty.channel.Channel;
*/ */
@Component @Component
@Slf4j @Slf4j
public class TaskEventProcessor implements NettyRequestProcessor { public class TaskWakeupProcessor implements NettyRequestProcessor {
@Autowired @Autowired
private StateEventResponseService stateEventResponseService; private StateEventResponseService stateEventResponseService;
@Override @Override
public void process(Channel channel, Command command) { public void process(Channel channel, Message message) {
Preconditions.checkArgument(CommandType.TASK_FORCE_STATE_EVENT_REQUEST == command.getType() TaskWakeupRequest taskEventChangeCommand =
|| CommandType.TASK_WAKEUP_EVENT_REQUEST == command.getType(), JSONUtils.parseObject(message.getBody(), TaskWakeupRequest.class);
String.format("invalid command type: %s", command.getType()));
TaskEventChangeCommand taskEventChangeCommand =
JSONUtils.parseObject(command.getBody(), TaskEventChangeCommand.class);
TaskStateEvent stateEvent = TaskStateEvent.builder() TaskStateEvent stateEvent = TaskStateEvent.builder()
.processInstanceId(taskEventChangeCommand.getProcessInstanceId()) .processInstanceId(taskEventChangeCommand.getProcessInstanceId())
.taskInstanceId(taskEventChangeCommand.getTaskInstanceId()) .taskInstanceId(taskEventChangeCommand.getTaskInstanceId())
@ -67,4 +62,9 @@ public class TaskEventProcessor implements NettyRequestProcessor {
} }
} }
@Override
public MessageType getCommandType() {
return MessageType.TASK_WAKEUP_EVENT_REQUEST;
}
} }

27
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/WorkflowExecutingDataRequestProcessor.java

@ -18,10 +18,10 @@
package org.apache.dolphinscheduler.server.master.processor; package org.apache.dolphinscheduler.server.master.processor;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.WorkflowExecutingDataRequestCommand; import org.apache.dolphinscheduler.remote.command.workflow.WorkflowExecutingDataRequest;
import org.apache.dolphinscheduler.remote.command.WorkflowExecutingDataResponseCommand; import org.apache.dolphinscheduler.remote.command.workflow.WorkflowExecutingDataResponse;
import org.apache.dolphinscheduler.remote.dto.WorkflowExecuteDto; import org.apache.dolphinscheduler.remote.dto.WorkflowExecuteDto;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.service.ExecutingService; import org.apache.dolphinscheduler.server.master.service.ExecutingService;
@ -33,7 +33,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel; import io.netty.channel.Channel;
/** /**
@ -47,20 +46,22 @@ public class WorkflowExecutingDataRequestProcessor implements NettyRequestProces
private ExecutingService executingService; private ExecutingService executingService;
@Override @Override
public void process(Channel channel, Command command) { public void process(Channel channel, Message message) {
Preconditions.checkArgument(CommandType.WORKFLOW_EXECUTING_DATA_REQUEST == command.getType(), WorkflowExecutingDataRequest requestCommand =
String.format("invalid command type: %s", command.getType())); JSONUtils.parseObject(message.getBody(), WorkflowExecutingDataRequest.class);
WorkflowExecutingDataRequestCommand requestCommand =
JSONUtils.parseObject(command.getBody(), WorkflowExecutingDataRequestCommand.class);
log.info("received command, processInstanceId:{}", requestCommand.getProcessInstanceId()); log.info("received command, processInstanceId:{}", requestCommand.getProcessInstanceId());
Optional<WorkflowExecuteDto> workflowExecuteDtoOptional = Optional<WorkflowExecuteDto> workflowExecuteDtoOptional =
executingService.queryWorkflowExecutingData(requestCommand.getProcessInstanceId()); executingService.queryWorkflowExecutingData(requestCommand.getProcessInstanceId());
WorkflowExecutingDataResponseCommand responseCommand = new WorkflowExecutingDataResponseCommand(); WorkflowExecutingDataResponse responseCommand = new WorkflowExecutingDataResponse();
workflowExecuteDtoOptional.ifPresent(responseCommand::setWorkflowExecuteDto); workflowExecuteDtoOptional.ifPresent(responseCommand::setWorkflowExecuteDto);
channel.writeAndFlush(responseCommand.convert2Command(command.getOpaque())); channel.writeAndFlush(responseCommand.convert2Command(message.getOpaque()));
}
@Override
public MessageType getCommandType() {
return MessageType.WORKFLOW_EXECUTING_DATA_REQUEST;
} }
} }

23
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/WorkflowMetricsCleanUpProcessor.java

@ -18,30 +18,31 @@
package org.apache.dolphinscheduler.server.master.processor; package org.apache.dolphinscheduler.server.master.processor;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.WorkflowMetricsCleanUpCommand; import org.apache.dolphinscheduler.remote.command.workflow.WorkflowMetricsCleanUpRequest;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.metrics.ProcessInstanceMetrics; import org.apache.dolphinscheduler.server.master.metrics.ProcessInstanceMetrics;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel; import io.netty.channel.Channel;
@Component @Component
public class WorkflowMetricsCleanUpProcessor implements NettyRequestProcessor { public class WorkflowMetricsCleanUpProcessor implements NettyRequestProcessor {
@Override @Override
public void process(Channel channel, Command command) { public void process(Channel channel, Message message) {
Preconditions.checkArgument(CommandType.WORKFLOW_METRICS_CLEANUP == command.getType(), WorkflowMetricsCleanUpRequest workflowMetricsCleanUpRequest =
String.format("invalid command type: %s", command.getType())); JSONUtils.parseObject(message.getBody(), WorkflowMetricsCleanUpRequest.class);
WorkflowMetricsCleanUpCommand workflowMetricsCleanUpCommand =
JSONUtils.parseObject(command.getBody(), WorkflowMetricsCleanUpCommand.class);
ProcessInstanceMetrics.cleanUpProcessInstanceCountMetricsByDefinitionCode( ProcessInstanceMetrics.cleanUpProcessInstanceCountMetricsByDefinitionCode(
workflowMetricsCleanUpCommand.getProcessDefinitionCode()); workflowMetricsCleanUpRequest.getProcessDefinitionCode());
}
@Override
public MessageType getCommandType() {
return MessageType.WORKFLOW_METRICS_CLEANUP;
} }
} }

4
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java

@ -20,7 +20,7 @@ package org.apache.dolphinscheduler.server.master.processor.queue;
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.plugin.task.api.utils.LogUtils;
import org.apache.dolphinscheduler.remote.command.StateEventResponseCommand; import org.apache.dolphinscheduler.remote.command.StateEventResponse;
import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager; import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager;
import org.apache.dolphinscheduler.server.master.event.StateEvent; import org.apache.dolphinscheduler.server.master.event.StateEvent;
import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable; import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable;
@ -133,7 +133,7 @@ public class StateEventResponseService {
private void writeResponse(StateEvent stateEvent) { private void writeResponse(StateEvent stateEvent) {
Channel channel = stateEvent.getChannel(); Channel channel = stateEvent.getChannel();
if (channel != null) { if (channel != null) {
StateEventResponseCommand command = new StateEventResponseCommand(stateEvent.getKey()); StateEventResponse command = new StateEventResponse(stateEvent.getKey());
channel.writeAndFlush(command.convert2Command()); channel.writeAndFlush(command.convert2Command());
} }
} }

16
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskEvent.java

@ -20,10 +20,10 @@ package org.apache.dolphinscheduler.server.master.processor.queue;
import org.apache.dolphinscheduler.common.enums.TaskEventType; import org.apache.dolphinscheduler.common.enums.TaskEventType;
import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.remote.command.TaskExecuteResultCommand; import org.apache.dolphinscheduler.remote.command.task.TaskExecuteResultMessage;
import org.apache.dolphinscheduler.remote.command.TaskExecuteRunningCommand; import org.apache.dolphinscheduler.remote.command.task.TaskExecuteRunningMessage;
import org.apache.dolphinscheduler.remote.command.TaskRejectCommand; import org.apache.dolphinscheduler.remote.command.task.TaskRejectMessage;
import org.apache.dolphinscheduler.remote.command.TaskUpdatePidCommand; import org.apache.dolphinscheduler.remote.command.task.TaskUpdatePidMessage;
import java.util.Date; import java.util.Date;
@ -112,7 +112,7 @@ public class TaskEvent {
return event; return event;
} }
public static TaskEvent newRunningEvent(TaskExecuteRunningCommand command, Channel channel, String workerAddress) { public static TaskEvent newRunningEvent(TaskExecuteRunningMessage command, Channel channel, String workerAddress) {
TaskEvent event = new TaskEvent(); TaskEvent event = new TaskEvent();
event.setProcessInstanceId(command.getProcessInstanceId()); event.setProcessInstanceId(command.getProcessInstanceId());
event.setTaskInstanceId(command.getTaskInstanceId()); event.setTaskInstanceId(command.getTaskInstanceId());
@ -127,7 +127,7 @@ public class TaskEvent {
return event; return event;
} }
public static TaskEvent newResultEvent(TaskExecuteResultCommand command, Channel channel, String workerAddress) { public static TaskEvent newResultEvent(TaskExecuteResultMessage command, Channel channel, String workerAddress) {
TaskEvent event = new TaskEvent(); TaskEvent event = new TaskEvent();
event.setProcessInstanceId(command.getProcessInstanceId()); event.setProcessInstanceId(command.getProcessInstanceId());
event.setTaskInstanceId(command.getTaskInstanceId()); event.setTaskInstanceId(command.getTaskInstanceId());
@ -145,7 +145,7 @@ public class TaskEvent {
return event; return event;
} }
public static TaskEvent newRecallEvent(TaskRejectCommand command, Channel channel) { public static TaskEvent newRecallEvent(TaskRejectMessage command, Channel channel) {
TaskEvent event = new TaskEvent(); TaskEvent event = new TaskEvent();
event.setTaskInstanceId(command.getTaskInstanceId()); event.setTaskInstanceId(command.getTaskInstanceId());
event.setProcessInstanceId(command.getProcessInstanceId()); event.setProcessInstanceId(command.getProcessInstanceId());
@ -163,7 +163,7 @@ public class TaskEvent {
return event; return event;
} }
public static TaskEvent newUpdatePidEvent(TaskUpdatePidCommand command, Channel channel, String workerAddress) { public static TaskEvent newUpdatePidEvent(TaskUpdatePidMessage command, Channel channel, String workerAddress) {
TaskEvent event = new TaskEvent(); TaskEvent event = new TaskEvent();
event.setProcessInstanceId(command.getProcessInstanceId()); event.setProcessInstanceId(command.getProcessInstanceId());
event.setTaskInstanceId(command.getTaskInstanceId()); event.setTaskInstanceId(command.getTaskInstanceId());

76
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/rpc/MasterRPCServer.java

@ -18,21 +18,11 @@
package org.apache.dolphinscheduler.server.master.rpc; 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.config.NettyServerConfig; import org.apache.dolphinscheduler.remote.config.NettyServerConfig;
import org.apache.dolphinscheduler.remote.processor.LoggerRequestProcessor; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
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.StateEventProcessor; import java.util.List;
import org.apache.dolphinscheduler.server.master.processor.TaskEventProcessor;
import org.apache.dolphinscheduler.server.master.processor.TaskExecuteResponseProcessor;
import org.apache.dolphinscheduler.server.master.processor.TaskExecuteRunningProcessor;
import org.apache.dolphinscheduler.server.master.processor.TaskExecuteStartProcessor;
import org.apache.dolphinscheduler.server.master.processor.TaskKillResponseProcessor;
import org.apache.dolphinscheduler.server.master.processor.TaskRecallProcessor;
import org.apache.dolphinscheduler.server.master.processor.TaskUpdatePidProcessor;
import org.apache.dolphinscheduler.server.master.processor.WorkflowExecutingDataRequestProcessor;
import org.apache.dolphinscheduler.server.master.processor.WorkflowMetricsCleanUpProcessor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -52,40 +42,7 @@ public class MasterRPCServer implements AutoCloseable {
private MasterConfig masterConfig; private MasterConfig masterConfig;
@Autowired @Autowired
private TaskExecuteRunningProcessor taskExecuteRunningProcessor; private List<NettyRequestProcessor> nettyRequestProcessors;
@Autowired
private TaskExecuteResponseProcessor taskExecuteResponseProcessor;
@Autowired
private TaskEventProcessor taskEventProcessor;
@Autowired
private StateEventProcessor stateEventProcessor;
@Autowired
private CacheProcessor cacheProcessor;
@Autowired
private TaskKillResponseProcessor taskKillResponseProcessor;
@Autowired
private TaskUpdatePidProcessor updatePidProcessor;
@Autowired
private TaskRecallProcessor taskRecallProcessor;
@Autowired
private LoggerRequestProcessor loggerRequestProcessor;
@Autowired
private WorkflowExecutingDataRequestProcessor workflowExecutingDataRequestProcessor;
@Autowired
private TaskExecuteStartProcessor taskExecuteStartProcessor;
@Autowired
private WorkflowMetricsCleanUpProcessor workflowMetricsCleanUpProcessor;
public void start() { public void start() {
log.info("Starting Master RPC Server..."); log.info("Starting Master RPC Server...");
@ -93,27 +50,10 @@ public class MasterRPCServer implements AutoCloseable {
NettyServerConfig serverConfig = new NettyServerConfig(); NettyServerConfig serverConfig = new NettyServerConfig();
serverConfig.setListenPort(masterConfig.getListenPort()); serverConfig.setListenPort(masterConfig.getListenPort());
this.nettyRemotingServer = new NettyRemotingServer(serverConfig); this.nettyRemotingServer = new NettyRemotingServer(serverConfig);
this.nettyRemotingServer.registerProcessor(CommandType.TASK_EXECUTE_RUNNING, taskExecuteRunningProcessor); for (NettyRequestProcessor nettyRequestProcessor : nettyRequestProcessors) {
this.nettyRemotingServer.registerProcessor(CommandType.TASK_UPDATE_PID, updatePidProcessor); this.nettyRemotingServer.registerProcessor(nettyRequestProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.TASK_EXECUTE_RESULT, taskExecuteResponseProcessor); log.info("Success register netty processor: {}", nettyRequestProcessor.getClass().getName());
this.nettyRemotingServer.registerProcessor(CommandType.TASK_KILL_RESPONSE, taskKillResponseProcessor); }
this.nettyRemotingServer.registerProcessor(CommandType.STATE_EVENT_REQUEST, stateEventProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.TASK_FORCE_STATE_EVENT_REQUEST, taskEventProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.TASK_WAKEUP_EVENT_REQUEST, taskEventProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.CACHE_EXPIRE, cacheProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.TASK_REJECT, taskRecallProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.WORKFLOW_EXECUTING_DATA_REQUEST,
workflowExecutingDataRequestProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.TASK_EXECUTE_START, taskExecuteStartProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.WORKFLOW_METRICS_CLEANUP,
workflowMetricsCleanUpProcessor);
// log server
this.nettyRemotingServer.registerProcessor(CommandType.GET_LOG_BYTES_REQUEST, loggerRequestProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.ROLL_VIEW_LOG_REQUEST, loggerRequestProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.VIEW_WHOLE_LOG_REQUEST, loggerRequestProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.REMOVE_TAK_LOG_REQUEST, loggerRequestProcessor);
this.nettyRemotingServer.start(); this.nettyRemotingServer.start();
log.info("Started Master RPC Server..."); log.info("Started Master RPC Server...");
} }

8
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/rpc/MasterRpcClient.java

@ -18,7 +18,7 @@
package org.apache.dolphinscheduler.server.master.rpc; package org.apache.dolphinscheduler.server.master.rpc;
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.Message;
import org.apache.dolphinscheduler.remote.config.NettyClientConfig; import org.apache.dolphinscheduler.remote.config.NettyClientConfig;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException; import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.remote.utils.Host;
@ -41,9 +41,9 @@ public class MasterRpcClient {
log.info("Success initialized ApiServerRPCClient..."); log.info("Success initialized ApiServerRPCClient...");
} }
public Command sendSyncCommand(@NonNull Host host, public Message sendSyncCommand(@NonNull Host host,
@NonNull Command rpcCommand) throws RemotingException, InterruptedException { @NonNull Message rpcMessage) throws RemotingException, InterruptedException {
return client.sendSync(host, rpcCommand, DEFAULT_TIME_OUT_MILLS); return client.sendSync(host, rpcMessage, DEFAULT_TIME_OUT_MILLS);
} }
} }

33
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/StreamTaskExecuteRunnable.java

@ -43,9 +43,9 @@ import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode;
import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper;
import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils; import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils; import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
import org.apache.dolphinscheduler.remote.command.TaskDispatchCommand; import org.apache.dolphinscheduler.remote.command.task.TaskDispatchMessage;
import org.apache.dolphinscheduler.remote.command.TaskExecuteRunningAckMessage; import org.apache.dolphinscheduler.remote.command.task.TaskExecuteRunningMessageAck;
import org.apache.dolphinscheduler.remote.command.TaskExecuteStartCommand; import org.apache.dolphinscheduler.remote.command.task.TaskExecuteStartMessage;
import org.apache.dolphinscheduler.server.master.builder.TaskExecutionContextBuilder; import org.apache.dolphinscheduler.server.master.builder.TaskExecutionContextBuilder;
import org.apache.dolphinscheduler.server.master.cache.StreamTaskInstanceExecCacheManager; import org.apache.dolphinscheduler.server.master.cache.StreamTaskInstanceExecCacheManager;
import org.apache.dolphinscheduler.server.master.config.MasterConfig; import org.apache.dolphinscheduler.server.master.config.MasterConfig;
@ -103,7 +103,7 @@ public class StreamTaskExecuteRunnable implements Runnable {
protected ProcessDefinition processDefinition; protected ProcessDefinition processDefinition;
protected TaskExecuteStartCommand taskExecuteStartCommand; protected TaskExecuteStartMessage taskExecuteStartMessage;
/** /**
* task event queue * task event queue
@ -112,7 +112,7 @@ public class StreamTaskExecuteRunnable implements Runnable {
private TaskRunnableStatus taskRunnableStatus = TaskRunnableStatus.CREATED; private TaskRunnableStatus taskRunnableStatus = TaskRunnableStatus.CREATED;
public StreamTaskExecuteRunnable(TaskDefinition taskDefinition, TaskExecuteStartCommand taskExecuteStartCommand) { public StreamTaskExecuteRunnable(TaskDefinition taskDefinition, TaskExecuteStartMessage taskExecuteStartMessage) {
this.processService = SpringApplicationContext.getBean(ProcessService.class); this.processService = SpringApplicationContext.getBean(ProcessService.class);
this.masterConfig = SpringApplicationContext.getBean(MasterConfig.class); this.masterConfig = SpringApplicationContext.getBean(MasterConfig.class);
this.dispatcher = SpringApplicationContext.getBean(ExecutorDispatcher.class); this.dispatcher = SpringApplicationContext.getBean(ExecutorDispatcher.class);
@ -122,7 +122,7 @@ public class StreamTaskExecuteRunnable implements Runnable {
this.streamTaskInstanceExecCacheManager = this.streamTaskInstanceExecCacheManager =
SpringApplicationContext.getBean(StreamTaskInstanceExecCacheManager.class); SpringApplicationContext.getBean(StreamTaskInstanceExecCacheManager.class);
this.taskDefinition = taskDefinition; this.taskDefinition = taskDefinition;
this.taskExecuteStartCommand = taskExecuteStartCommand; this.taskExecuteStartMessage = taskExecuteStartMessage;
} }
public TaskInstance getTaskInstance() { public TaskInstance getTaskInstance() {
@ -153,7 +153,7 @@ public class StreamTaskExecuteRunnable implements Runnable {
return; return;
} }
TaskDispatchCommand dispatchCommand = new TaskDispatchCommand(taskExecutionContext, TaskDispatchMessage dispatchCommand = new TaskDispatchMessage(taskExecutionContext,
masterConfig.getMasterAddress(), masterConfig.getMasterAddress(),
taskExecutionContext.getHost(), taskExecutionContext.getHost(),
System.currentTimeMillis()); System.currentTimeMillis());
@ -296,7 +296,7 @@ public class StreamTaskExecuteRunnable implements Runnable {
taskInstance.setDelayTime(taskDefinition.getDelayTime()); taskInstance.setDelayTime(taskDefinition.getDelayTime());
// task dry run flag // task dry run flag
taskInstance.setDryRun(taskExecuteStartCommand.getDryRun()); taskInstance.setDryRun(taskExecuteStartMessage.getDryRun());
taskInstance.setWorkerGroup(StringUtils.isBlank(taskDefinition.getWorkerGroup()) ? DEFAULT_WORKER_GROUP taskInstance.setWorkerGroup(StringUtils.isBlank(taskDefinition.getWorkerGroup()) ? DEFAULT_WORKER_GROUP
: taskDefinition.getWorkerGroup()); : taskDefinition.getWorkerGroup());
@ -318,8 +318,8 @@ public class StreamTaskExecuteRunnable implements Runnable {
} }
taskInstance.setTaskExecuteType(taskDefinition.getTaskExecuteType()); taskInstance.setTaskExecuteType(taskDefinition.getTaskExecuteType());
taskInstance.setExecutorId(taskExecuteStartCommand.getExecutorId()); taskInstance.setExecutorId(taskExecuteStartMessage.getExecutorId());
taskInstance.setExecutorName(taskExecuteStartCommand.getExecutorName()); taskInstance.setExecutorName(taskExecuteStartMessage.getExecutorName());
return taskInstance; return taskInstance;
} }
@ -461,7 +461,7 @@ public class StreamTaskExecuteRunnable implements Runnable {
public Map<String, Property> paramParsingPreparation(@NonNull TaskInstance taskInstance, public Map<String, Property> paramParsingPreparation(@NonNull TaskInstance taskInstance,
@NonNull AbstractParameters parameters) { @NonNull AbstractParameters parameters) {
// assign value to definedParams here // assign value to definedParams here
Map<String, String> globalParamsMap = taskExecuteStartCommand.getStartParams(); Map<String, String> globalParamsMap = taskExecuteStartMessage.getStartParams();
Map<String, Property> globalParams = ParamUtils.getUserDefParamsMap(globalParamsMap); Map<String, Property> globalParams = ParamUtils.getUserDefParamsMap(globalParamsMap);
// combining local and global parameters // combining local and global parameters
@ -487,9 +487,14 @@ public class StreamTaskExecuteRunnable implements Runnable {
private void sendAckToWorker(TaskEvent taskEvent) { private void sendAckToWorker(TaskEvent taskEvent) {
// If event handle success, send ack to worker to otherwise the worker will retry this event // If event handle success, send ack to worker to otherwise the worker will retry this event
TaskExecuteRunningAckMessage taskExecuteRunningAckMessage = TaskExecuteRunningMessageAck taskExecuteRunningMessageAck =
new TaskExecuteRunningAckMessage(true, taskEvent.getTaskInstanceId()); new TaskExecuteRunningMessageAck(
taskEvent.getChannel().writeAndFlush(taskExecuteRunningAckMessage.convert2Command()); true,
taskEvent.getTaskInstanceId(),
masterConfig.getMasterAddress(),
taskEvent.getWorkerAddress(),
System.currentTimeMillis());
taskEvent.getChannel().writeAndFlush(taskExecuteRunningMessageAck.convert2Command());
} }
private enum TaskRunnableStatus { private enum TaskRunnableStatus {

14
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteRunnable.java

@ -67,6 +67,8 @@ 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.model.Property; import org.apache.dolphinscheduler.plugin.task.api.model.Property;
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils; import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.task.TaskWakeupRequest;
import org.apache.dolphinscheduler.remote.command.task.WorkflowHostChangeRequest; import org.apache.dolphinscheduler.remote.command.task.WorkflowHostChangeRequest;
import org.apache.dolphinscheduler.remote.command.task.WorkflowHostChangeResponse; import org.apache.dolphinscheduler.remote.command.task.WorkflowHostChangeResponse;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException; import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
@ -476,7 +478,7 @@ public class WorkflowExecuteRunnable implements Callable<WorkflowSubmitStatue> {
* release task group * release task group
* *
*/ */
public void releaseTaskGroup(TaskInstance taskInstance) { public void releaseTaskGroup(TaskInstance taskInstance) throws RemotingException, InterruptedException {
if (taskInstance.getTaskGroupId() > 0) { if (taskInstance.getTaskGroupId() > 0) {
TaskInstance nextTaskInstance = this.processService.releaseTaskGroup(taskInstance); TaskInstance nextTaskInstance = this.processService.releaseTaskGroup(taskInstance);
if (nextTaskInstance != null) { if (nextTaskInstance != null) {
@ -490,8 +492,8 @@ public class WorkflowExecuteRunnable implements Callable<WorkflowSubmitStatue> {
} else { } else {
ProcessInstance processInstance = ProcessInstance processInstance =
this.processService.findProcessInstanceById(nextTaskInstance.getProcessInstanceId()); this.processService.findProcessInstanceById(nextTaskInstance.getProcessInstanceId());
this.processService.sendStartTask2Master(processInstance, nextTaskInstance.getId(), this.masterRpcClient.sendSyncCommand(Host.of(processInstance.getHost()),
org.apache.dolphinscheduler.remote.command.CommandType.TASK_WAKEUP_EVENT_REQUEST); new TaskWakeupRequest(processInstance.getId(), nextTaskInstance.getId()).convert2Command());
} }
} }
} }
@ -1420,17 +1422,17 @@ public class WorkflowExecuteRunnable implements Callable<WorkflowSubmitStatue> {
return false; return false;
} }
try { try {
org.apache.dolphinscheduler.remote.command.Command command = Message message =
masterRpcClient.sendSyncCommand(Host.of(taskInstance.getHost()), masterRpcClient.sendSyncCommand(Host.of(taskInstance.getHost()),
new WorkflowHostChangeRequest(taskInstance.getId(), masterAddress).convert2Command()); new WorkflowHostChangeRequest(taskInstance.getId(), masterAddress).convert2Command());
if (command == null) { if (message == null) {
log.error( log.error(
"Takeover task instance failed, the worker {} might not be alive, will try to create a new task instance", "Takeover task instance failed, the worker {} might not be alive, will try to create a new task instance",
taskInstance.getHost()); taskInstance.getHost());
return false; return false;
} }
WorkflowHostChangeResponse workflowHostChangeResponse = WorkflowHostChangeResponse workflowHostChangeResponse =
JSONUtils.parseObject(command.getBody(), WorkflowHostChangeResponse.class); JSONUtils.parseObject(message.getBody(), WorkflowHostChangeResponse.class);
if (workflowHostChangeResponse == null || !workflowHostChangeResponse.isSuccess()) { if (workflowHostChangeResponse == null || !workflowHostChangeResponse.isSuccess()) {
log.error( log.error(
"Takeover task instance failed, receive a failed response from worker: {}, will try to create a new task instance", "Takeover task instance failed, receive a failed response from worker: {}, will try to create a new task instance",

6
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThreadPool.java

@ -24,7 +24,7 @@ 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.plugin.task.api.enums.TaskExecutionStatus; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils; import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
import org.apache.dolphinscheduler.remote.command.WorkflowStateEventChangeCommand; import org.apache.dolphinscheduler.remote.command.workflow.WorkflowStateEventChangeRequest;
import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService;
import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.remote.utils.Host;
import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager; import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager;
@ -203,10 +203,10 @@ public class WorkflowExecuteThreadPool extends ThreadPoolTaskExecutor {
taskInstance.getName(), taskInstance.getId()); taskInstance.getName(), taskInstance.getId());
return; return;
} }
WorkflowStateEventChangeCommand workflowStateEventChangeCommand = new WorkflowStateEventChangeCommand( WorkflowStateEventChangeRequest workflowStateEventChangeRequest = new WorkflowStateEventChangeRequest(
finishProcessInstance.getId(), 0, finishProcessInstance.getState(), processInstance.getId(), finishProcessInstance.getId(), 0, finishProcessInstance.getState(), processInstance.getId(),
taskInstance.getId()); taskInstance.getId());
Host host = new Host(processInstanceHost); Host host = new Host(processInstanceHost);
stateEventCallbackService.sendResult(host, workflowStateEventChangeCommand.convert2Command()); stateEventCallbackService.sendResult(host, workflowStateEventChangeRequest.convert2Command());
} }
} }

4
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/CommonTaskProcessor.java

@ -23,7 +23,7 @@ import org.apache.dolphinscheduler.common.utils.JSONUtils;
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.enums.TaskExecutionStatus; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.remote.command.TaskKillRequestCommand; import org.apache.dolphinscheduler.remote.command.task.TaskKillRequest;
import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.remote.utils.Host;
import org.apache.dolphinscheduler.server.master.dispatch.context.ExecutionContext; import org.apache.dolphinscheduler.server.master.dispatch.context.ExecutionContext;
import org.apache.dolphinscheduler.server.master.dispatch.enums.ExecutorType; import org.apache.dolphinscheduler.server.master.dispatch.enums.ExecutorType;
@ -173,7 +173,7 @@ public class CommonTaskProcessor extends BaseTaskProcessor {
} }
private void killRemoteTask() throws ExecuteException { private void killRemoteTask() throws ExecuteException {
TaskKillRequestCommand killCommand = new TaskKillRequestCommand(); TaskKillRequest killCommand = new TaskKillRequest();
killCommand.setTaskInstanceId(taskInstance.getId()); killCommand.setTaskInstanceId(taskInstance.getId());
ExecutionContext executionContext = ExecutionContext executionContext =

6
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/SubTaskProcessor.java

@ -29,7 +29,7 @@ import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
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;
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils; import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
import org.apache.dolphinscheduler.remote.command.WorkflowStateEventChangeCommand; import org.apache.dolphinscheduler.remote.command.workflow.WorkflowStateEventChangeRequest;
import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService;
import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.remote.utils.Host;
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
@ -224,11 +224,11 @@ public class SubTaskProcessor extends BaseTaskProcessor {
} }
private void sendToSubProcess() { private void sendToSubProcess() {
WorkflowStateEventChangeCommand workflowStateEventChangeCommand = new WorkflowStateEventChangeCommand( WorkflowStateEventChangeRequest workflowStateEventChangeRequest = new WorkflowStateEventChangeRequest(
processInstance.getId(), taskInstance.getId(), subProcessInstance.getState(), processInstance.getId(), taskInstance.getId(), subProcessInstance.getState(),
subProcessInstance.getId(), 0); subProcessInstance.getId(), 0);
Host host = new Host(subProcessInstance.getHost()); Host host = new Host(subProcessInstance.getHost());
this.stateEventCallbackService.sendResult(host, workflowStateEventChangeCommand.convert2Command()); this.stateEventCallbackService.sendResult(host, workflowStateEventChangeRequest.convert2Command());
} }
@Override @Override

4
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/MasterCommandTest.java → dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/MasterMessageTest.java

@ -33,9 +33,9 @@ import org.slf4j.LoggerFactory;
* master test * master test
*/ */
@Disabled @Disabled
public class MasterCommandTest { public class MasterMessageTest {
private final Logger logger = LoggerFactory.getLogger(MasterCommandTest.class); private final Logger logger = LoggerFactory.getLogger(MasterMessageTest.class);
private CommandMapper commandMapper; private CommandMapper commandMapper;

10
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutionContextTestUtils.java

@ -23,8 +23,8 @@ import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
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.plugin.task.api.TaskExecutionContext; import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.TaskDispatchCommand; import org.apache.dolphinscheduler.remote.command.task.TaskDispatchMessage;
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;
import org.apache.dolphinscheduler.server.master.dispatch.context.ExecutionContext; import org.apache.dolphinscheduler.server.master.dispatch.context.ExecutionContext;
@ -52,13 +52,13 @@ public class ExecutionContextTestUtils {
.buildProcessDefinitionRelatedInfo(processDefinition) .buildProcessDefinitionRelatedInfo(processDefinition)
.create(); .create();
TaskDispatchCommand requestCommand = new TaskDispatchCommand(context, TaskDispatchMessage requestCommand = new TaskDispatchMessage(context,
"127.0.0.1:5678", "127.0.0.1:5678",
"127.0.0.1:5678", "127.0.0.1:5678",
System.currentTimeMillis()); System.currentTimeMillis());
Command command = requestCommand.convert2Command(); Message message = requestCommand.convert2Command();
ExecutionContext executionContext = new ExecutionContext(command, ExecutorType.WORKER, taskInstance); ExecutionContext executionContext = new ExecutionContext(message, ExecutorType.WORKER, taskInstance);
executionContext.setHost(Host.of(NetUtils.getAddr(port))); executionContext.setHost(Host.of(NetUtils.getAddr(port)));
return executionContext; return executionContext;

4
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutorDispatcherTest.java

@ -18,7 +18,6 @@
package org.apache.dolphinscheduler.server.master.dispatch; package org.apache.dolphinscheduler.server.master.dispatch;
import org.apache.dolphinscheduler.remote.NettyRemotingServer; import org.apache.dolphinscheduler.remote.NettyRemotingServer;
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.server.master.dispatch.context.ExecutionContext; import org.apache.dolphinscheduler.server.master.dispatch.context.ExecutionContext;
import org.apache.dolphinscheduler.server.master.dispatch.exceptions.ExecuteException; import org.apache.dolphinscheduler.server.master.dispatch.exceptions.ExecuteException;
@ -64,8 +63,7 @@ public class ExecutorDispatcherTest {
final NettyServerConfig serverConfig = new NettyServerConfig(); final NettyServerConfig serverConfig = new NettyServerConfig();
serverConfig.setListenPort(port); serverConfig.setListenPort(port);
NettyRemotingServer nettyRemotingServer = new NettyRemotingServer(serverConfig); NettyRemotingServer nettyRemotingServer = new NettyRemotingServer(serverConfig);
nettyRemotingServer.registerProcessor(CommandType.TASK_DISPATCH_REQUEST, Mockito.mock( nettyRemotingServer.registerProcessor(Mockito.mock(TaskDispatchProcessor.class));
TaskDispatchProcessor.class));
nettyRemotingServer.start(); nettyRemotingServer.start();
// //
workerConfig.setListenPort(port); workerConfig.setListenPort(port);

12
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManagerTest.java

@ -24,8 +24,8 @@ 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.plugin.task.api.TaskExecutionContext; import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
import org.apache.dolphinscheduler.remote.NettyRemotingServer; import org.apache.dolphinscheduler.remote.NettyRemotingServer;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.TaskDispatchCommand; import org.apache.dolphinscheduler.remote.command.task.TaskDispatchMessage;
import org.apache.dolphinscheduler.remote.config.NettyServerConfig; import org.apache.dolphinscheduler.remote.config.NettyServerConfig;
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;
@ -56,9 +56,7 @@ public class NettyExecutorManagerTest {
final NettyServerConfig serverConfig = new NettyServerConfig(); final NettyServerConfig serverConfig = new NettyServerConfig();
serverConfig.setListenPort(30000); serverConfig.setListenPort(30000);
NettyRemotingServer nettyRemotingServer = new NettyRemotingServer(serverConfig); NettyRemotingServer nettyRemotingServer = new NettyRemotingServer(serverConfig);
nettyRemotingServer.registerProcessor( nettyRemotingServer.registerProcessor(new TaskDispatchProcessor());
org.apache.dolphinscheduler.remote.command.CommandType.TASK_DISPATCH_REQUEST,
new TaskDispatchProcessor());
nettyRemotingServer.start(); nettyRemotingServer.start();
TaskInstance taskInstance = Mockito.mock(TaskInstance.class); TaskInstance taskInstance = Mockito.mock(TaskInstance.class);
ProcessDefinition processDefinition = Mockito.mock(ProcessDefinition.class); ProcessDefinition processDefinition = Mockito.mock(ProcessDefinition.class);
@ -95,8 +93,8 @@ public class NettyExecutorManagerTest {
}); });
} }
private Command toCommand(TaskExecutionContext taskExecutionContext) { private Message toCommand(TaskExecutionContext taskExecutionContext) {
TaskDispatchCommand requestCommand = new TaskDispatchCommand(taskExecutionContext, TaskDispatchMessage requestCommand = new TaskDispatchMessage(taskExecutionContext,
"127.0.0.1:5678", "127.0.0.1:5678",
"127.0.0.1:1234", "127.0.0.1:1234",
System.currentTimeMillis()); System.currentTimeMillis());

10
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/CacheProcessorTest.java

@ -19,8 +19,8 @@ package org.apache.dolphinscheduler.server.master.processor;
import org.apache.dolphinscheduler.common.enums.CacheType; import org.apache.dolphinscheduler.common.enums.CacheType;
import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.Tenant;
import org.apache.dolphinscheduler.remote.command.CacheExpireCommand; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.cache.CacheExpireRequest;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -61,9 +61,9 @@ public class CacheProcessorTest {
public void testProcess() { public void testProcess() {
Tenant tenant = new Tenant(); Tenant tenant = new Tenant();
tenant.setId(1); tenant.setId(1);
CacheExpireCommand cacheExpireCommand = new CacheExpireCommand(CacheType.TENANT, "1"); CacheExpireRequest cacheExpireRequest = new CacheExpireRequest(CacheType.TENANT, "1");
Command command = cacheExpireCommand.convert2Command(); Message message = cacheExpireRequest.convert2Command();
cacheProcessor.process(channel, command); cacheProcessor.process(channel, message);
} }
} }

6
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskAckProcessorTest.java

@ -18,7 +18,7 @@
package org.apache.dolphinscheduler.server.master.processor; package org.apache.dolphinscheduler.server.master.processor;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.remote.command.TaskExecuteRunningCommand; import org.apache.dolphinscheduler.remote.command.task.TaskExecuteRunningMessage;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent; import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEventService; import org.apache.dolphinscheduler.server.master.processor.queue.TaskEventService;
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
@ -43,7 +43,7 @@ public class TaskAckProcessorTest {
private TaskExecuteRunningProcessor taskExecuteRunningProcessor; private TaskExecuteRunningProcessor taskExecuteRunningProcessor;
private TaskEventService taskEventService; private TaskEventService taskEventService;
private ProcessService processService; private ProcessService processService;
private TaskExecuteRunningCommand taskExecuteRunningMessage; private TaskExecuteRunningMessage taskExecuteRunningMessage;
private TaskEvent taskResponseEvent; private TaskEvent taskResponseEvent;
private Channel channel; private Channel channel;
@ -66,7 +66,7 @@ public class TaskAckProcessorTest {
channel = Mockito.mock(Channel.class); channel = Mockito.mock(Channel.class);
taskResponseEvent = Mockito.mock(TaskEvent.class); taskResponseEvent = Mockito.mock(TaskEvent.class);
taskExecuteRunningMessage = new TaskExecuteRunningCommand("127.0.0.1:5678", taskExecuteRunningMessage = new TaskExecuteRunningMessage("127.0.0.1:5678",
" 127.0.0.1:1234", " 127.0.0.1:1234",
System.currentTimeMillis()); System.currentTimeMillis());
taskExecuteRunningMessage.setStatus(TaskExecutionStatus.RUNNING_EXECUTION); taskExecuteRunningMessage.setStatus(TaskExecutionStatus.RUNNING_EXECUTION);

26
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskKillResponseProcessorTest.java

@ -18,9 +18,9 @@
package org.apache.dolphinscheduler.server.master.processor; package org.apache.dolphinscheduler.server.master.processor;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.TaskKillResponseCommand; import org.apache.dolphinscheduler.remote.command.task.TaskKillResponse;
import java.util.ArrayList; import java.util.ArrayList;
@ -38,7 +38,7 @@ public class TaskKillResponseProcessorTest {
private TaskKillResponseProcessor taskKillResponseProcessor; private TaskKillResponseProcessor taskKillResponseProcessor;
private TaskKillResponseCommand taskKillResponseCommand; private TaskKillResponse taskKillResponse;
private Channel channel; private Channel channel;
@ -46,25 +46,25 @@ public class TaskKillResponseProcessorTest {
public void before() { public void before() {
taskKillResponseProcessor = new TaskKillResponseProcessor(); taskKillResponseProcessor = new TaskKillResponseProcessor();
channel = Mockito.mock(Channel.class); channel = Mockito.mock(Channel.class);
taskKillResponseCommand = new TaskKillResponseCommand(); taskKillResponse = new TaskKillResponse();
taskKillResponseCommand.setAppIds( taskKillResponse.setAppIds(
new ArrayList<String>() { new ArrayList<String>() {
{ {
add("task_1"); add("task_1");
} }
}); });
taskKillResponseCommand.setHost("localhost"); taskKillResponse.setHost("localhost");
taskKillResponseCommand.setProcessId(1); taskKillResponse.setProcessId(1);
taskKillResponseCommand.setStatus(TaskExecutionStatus.RUNNING_EXECUTION); taskKillResponse.setStatus(TaskExecutionStatus.RUNNING_EXECUTION);
taskKillResponseCommand.setTaskInstanceId(1); taskKillResponse.setTaskInstanceId(1);
} }
@Test @Test
public void testProcess() { public void testProcess() {
Command command = taskKillResponseCommand.convert2Command(); Message message = taskKillResponse.convert2Command(1);
Assertions.assertEquals(CommandType.TASK_KILL_RESPONSE, command.getType()); Assertions.assertEquals(MessageType.TASK_KILL_RESPONSE, message.getType());
taskKillResponseProcessor.process(channel, command); taskKillResponseProcessor.process(channel, message);
} }
} }

8
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseServiceTest.java

@ -20,8 +20,8 @@ package org.apache.dolphinscheduler.server.master.processor.queue;
import org.apache.dolphinscheduler.common.utils.NetUtils; import org.apache.dolphinscheduler.common.utils.NetUtils;
import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.remote.command.TaskExecuteResultCommand; import org.apache.dolphinscheduler.remote.command.task.TaskExecuteResultMessage;
import org.apache.dolphinscheduler.remote.command.TaskExecuteRunningCommand; import org.apache.dolphinscheduler.remote.command.task.TaskExecuteRunningMessage;
import org.apache.dolphinscheduler.server.master.cache.impl.ProcessInstanceExecCacheManagerImpl; import org.apache.dolphinscheduler.server.master.cache.impl.ProcessInstanceExecCacheManagerImpl;
import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThreadPool; import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThreadPool;
import org.apache.dolphinscheduler.server.master.utils.DataQualityResultOperator; import org.apache.dolphinscheduler.server.master.utils.DataQualityResultOperator;
@ -71,7 +71,7 @@ public class TaskResponseServiceTest {
public void before() { public void before() {
taskEventService.start(); taskEventService.start();
TaskExecuteRunningCommand taskExecuteRunningMessage = new TaskExecuteRunningCommand("127.0.0.1:5678", TaskExecuteRunningMessage taskExecuteRunningMessage = new TaskExecuteRunningMessage("127.0.0.1:5678",
"127.0.0.1:1234", "127.0.0.1:1234",
System.currentTimeMillis()); System.currentTimeMillis());
taskExecuteRunningMessage.setProcessId(1); taskExecuteRunningMessage.setProcessId(1);
@ -86,7 +86,7 @@ public class TaskResponseServiceTest {
channel, channel,
taskExecuteRunningMessage.getMessageSenderAddress()); taskExecuteRunningMessage.getMessageSenderAddress());
TaskExecuteResultCommand taskExecuteResultMessage = new TaskExecuteResultCommand(NetUtils.getAddr(1234), TaskExecuteResultMessage taskExecuteResultMessage = new TaskExecuteResultMessage(NetUtils.getAddr(1234),
NetUtils.getAddr(5678), NetUtils.getAddr(5678),
System.currentTimeMillis()); System.currentTimeMillis());
taskExecuteResultMessage.setProcessInstanceId(1); taskExecuteResultMessage.setProcessInstanceId(1);

41
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/NettyRemotingClient.java

@ -19,8 +19,7 @@ package org.apache.dolphinscheduler.remote;
import org.apache.dolphinscheduler.remote.codec.NettyDecoder; import org.apache.dolphinscheduler.remote.codec.NettyDecoder;
import org.apache.dolphinscheduler.remote.codec.NettyEncoder; import org.apache.dolphinscheduler.remote.codec.NettyEncoder;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.config.NettyClientConfig; import org.apache.dolphinscheduler.remote.config.NettyClientConfig;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException; import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
import org.apache.dolphinscheduler.remote.exceptions.RemotingTimeoutException; import org.apache.dolphinscheduler.remote.exceptions.RemotingTimeoutException;
@ -142,7 +141,7 @@ public class NettyRemotingClient implements AutoCloseable {
* @param timeoutMillis timeoutMillis * @param timeoutMillis timeoutMillis
* @param invokeCallback callback function * @param invokeCallback callback function
*/ */
public void sendAsync(final Host host, final Command command, public void sendAsync(final Host host, final Message command,
final long timeoutMillis, final long timeoutMillis,
final InvokeCallback invokeCallback) throws InterruptedException, RemotingException { final InvokeCallback invokeCallback) throws InterruptedException, RemotingException {
final Channel channel = getChannel(host); final Channel channel = getChannel(host);
@ -201,19 +200,19 @@ public class NettyRemotingClient implements AutoCloseable {
* sync send * sync send
* *
* @param host host * @param host host
* @param command command * @param message command
* @param timeoutMillis timeoutMillis * @param timeoutMillis timeoutMillis
* @return command * @return command
*/ */
public Command sendSync(final Host host, final Command command, public Message sendSync(final Host host, final Message message,
final long timeoutMillis) throws InterruptedException, RemotingException { final long timeoutMillis) throws InterruptedException, RemotingException {
final Channel channel = getChannel(host); final Channel channel = getChannel(host);
if (channel == null) { if (channel == null) {
throw new RemotingException(String.format("connect to : %s fail", host)); throw new RemotingException(String.format("connect to : %s fail", host));
} }
final long opaque = command.getOpaque(); final long opaque = message.getOpaque();
final ResponseFuture responseFuture = new ResponseFuture(opaque, timeoutMillis, null, null); final ResponseFuture responseFuture = new ResponseFuture(opaque, timeoutMillis, null, null);
channel.writeAndFlush(command).addListener(future -> { channel.writeAndFlush(message).addListener(future -> {
if (future.isSuccess()) { if (future.isSuccess()) {
responseFuture.setSendOk(true); responseFuture.setSendOk(true);
return; return;
@ -222,12 +221,12 @@ public class NettyRemotingClient implements AutoCloseable {
} }
responseFuture.setCause(future.cause()); responseFuture.setCause(future.cause());
responseFuture.putResponse(null); responseFuture.putResponse(null);
log.error("send command {} to host {} failed", command, host); log.error("send command {} to host {} failed", message, host);
}); });
/* /*
* sync wait for result * sync wait for result
*/ */
Command result = responseFuture.waitResponse(); Message result = responseFuture.waitResponse();
if (result == null) { if (result == null) {
if (responseFuture.isSendOK()) { if (responseFuture.isSendOK()) {
throw new RemotingTimeoutException(host.toString(), timeoutMillis, responseFuture.getCause()); throw new RemotingTimeoutException(host.toString(), timeoutMillis, responseFuture.getCause());
@ -242,51 +241,49 @@ public class NettyRemotingClient implements AutoCloseable {
* send task * send task
* *
* @param host host * @param host host
* @param command command * @param message command
*/ */
public void send(final Host host, final Command command) throws RemotingException { public void send(final Host host, final Message message) throws RemotingException {
Channel channel = getChannel(host); Channel channel = getChannel(host);
if (channel == null) { if (channel == null) {
throw new RemotingException(String.format("connect to : %s fail", host)); throw new RemotingException(String.format("connect to : %s fail", host));
} }
try { try {
ChannelFuture future = channel.writeAndFlush(command).await(); ChannelFuture future = channel.writeAndFlush(message).await();
if (future.isSuccess()) { if (future.isSuccess()) {
log.debug("send command : {} , to : {} successfully.", command, host.getAddress()); log.debug("send command : {} , to : {} successfully.", message, host.getAddress());
} else { } else {
String msg = String.format("send command : %s , to :%s failed", command, host.getAddress()); String msg = String.format("send command : %s , to :%s failed", message, host.getAddress());
log.error(msg, future.cause()); log.error(msg, future.cause());
throw new RemotingException(msg); throw new RemotingException(msg);
} }
} catch (RemotingException remotingException) { } catch (RemotingException remotingException) {
throw remotingException; throw remotingException;
} catch (Exception e) { } catch (Exception e) {
log.error("Send command {} to address {} encounter error.", command, host.getAddress()); log.error("Send command {} to address {} encounter error.", message, host.getAddress());
throw new RemotingException( throw new RemotingException(
String.format("Send command : %s , to :%s encounter error", command, host.getAddress()), e); String.format("Send command : %s , to :%s encounter error", message, host.getAddress()), e);
} }
} }
/** /**
* register processor * register processor
* *
* @param commandType command type
* @param processor processor * @param processor processor
*/ */
public void registerProcessor(final CommandType commandType, final NettyRequestProcessor processor) { public void registerProcessor(final NettyRequestProcessor processor) {
this.registerProcessor(commandType, processor, null); this.registerProcessor(processor, null);
} }
/** /**
* register processor * register processor
* *
* @param commandType command type
* @param processor processor * @param processor processor
* @param executor thread executor * @param executor thread executor
*/ */
public void registerProcessor(final CommandType commandType, final NettyRequestProcessor processor, public void registerProcessor(final NettyRequestProcessor processor,
final ExecutorService executor) { final ExecutorService executor) {
this.clientHandler.registerProcessor(commandType, processor, executor); this.clientHandler.registerProcessor(processor.getCommandType(), processor, executor);
} }
/** /**

11
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/NettyRemotingServer.java

@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.remote;
import org.apache.dolphinscheduler.remote.codec.NettyDecoder; import org.apache.dolphinscheduler.remote.codec.NettyDecoder;
import org.apache.dolphinscheduler.remote.codec.NettyEncoder; import org.apache.dolphinscheduler.remote.codec.NettyEncoder;
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.exceptions.RemoteException; import org.apache.dolphinscheduler.remote.exceptions.RemoteException;
import org.apache.dolphinscheduler.remote.handler.NettyServerHandler; import org.apache.dolphinscheduler.remote.handler.NettyServerHandler;
@ -171,23 +170,21 @@ public class NettyRemotingServer {
/** /**
* register processor * register processor
* *
* @param commandType command type
* @param processor processor * @param processor processor
*/ */
public void registerProcessor(final CommandType commandType, final NettyRequestProcessor processor) { public void registerProcessor(final NettyRequestProcessor processor) {
this.registerProcessor(commandType, processor, null); this.registerProcessor(processor, null);
} }
/** /**
* register processor * register processor
* *
* @param commandType command type
* @param processor processor * @param processor processor
* @param executor thread executor * @param executor thread executor
*/ */
public void registerProcessor(final CommandType commandType, final NettyRequestProcessor processor, public void registerProcessor(final NettyRequestProcessor processor,
final ExecutorService executor) { final ExecutorService executor) {
this.serverHandler.registerProcessor(commandType, processor, executor); this.serverHandler.registerProcessor(processor.getCommandType(), processor, executor);
} }
/** /**

40
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/codec/NettyDecoder.java

@ -17,10 +17,10 @@
package org.apache.dolphinscheduler.remote.codec; package org.apache.dolphinscheduler.remote.codec;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.CommandContext; import org.apache.dolphinscheduler.remote.command.MessageContext;
import org.apache.dolphinscheduler.remote.command.CommandHeader; import org.apache.dolphinscheduler.remote.command.MessageHeader;
import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.MessageType;
import java.util.List; import java.util.List;
@ -39,7 +39,7 @@ public class NettyDecoder extends ReplayingDecoder<NettyDecoder.State> {
super(State.MAGIC); super(State.MAGIC);
} }
private final CommandHeader commandHeader = new CommandHeader(); private final MessageHeader messageHeader = new MessageHeader();
/** /**
* decode * decode
@ -60,35 +60,35 @@ public class NettyDecoder extends ReplayingDecoder<NettyDecoder.State> {
checkpoint(State.COMMAND); checkpoint(State.COMMAND);
// fallthru // fallthru
case COMMAND: case COMMAND:
commandHeader.setType(in.readByte()); messageHeader.setType(in.readByte());
checkpoint(State.OPAQUE); checkpoint(State.OPAQUE);
// fallthru // fallthru
case OPAQUE: case OPAQUE:
commandHeader.setOpaque(in.readLong()); messageHeader.setOpaque(in.readLong());
checkpoint(State.CONTEXT_LENGTH); checkpoint(State.CONTEXT_LENGTH);
// fallthru // fallthru
case CONTEXT_LENGTH: case CONTEXT_LENGTH:
commandHeader.setContextLength(in.readInt()); messageHeader.setContextLength(in.readInt());
checkpoint(State.CONTEXT); checkpoint(State.CONTEXT);
// fallthru // fallthru
case CONTEXT: case CONTEXT:
byte[] context = new byte[commandHeader.getContextLength()]; byte[] context = new byte[messageHeader.getContextLength()];
in.readBytes(context); in.readBytes(context);
commandHeader.setContext(context); messageHeader.setContext(context);
checkpoint(State.BODY_LENGTH); checkpoint(State.BODY_LENGTH);
// fallthru // fallthru
case BODY_LENGTH: case BODY_LENGTH:
commandHeader.setBodyLength(in.readInt()); messageHeader.setBodyLength(in.readInt());
checkpoint(State.BODY); checkpoint(State.BODY);
// fallthru // fallthru
case BODY: case BODY:
byte[] body = new byte[commandHeader.getBodyLength()]; byte[] body = new byte[messageHeader.getBodyLength()];
in.readBytes(body); in.readBytes(body);
// //
Command packet = new Command(); Message packet = new Message();
packet.setType(commandType(commandHeader.getType())); packet.setType(commandType(messageHeader.getType()));
packet.setOpaque(commandHeader.getOpaque()); packet.setOpaque(messageHeader.getOpaque());
packet.setContext(CommandContext.valueOf(commandHeader.getContext())); packet.setContext(MessageContext.valueOf(messageHeader.getContext()));
packet.setBody(body); packet.setBody(body);
out.add(packet); out.add(packet);
// //
@ -104,8 +104,8 @@ public class NettyDecoder extends ReplayingDecoder<NettyDecoder.State> {
* *
* @param type type * @param type type
*/ */
private CommandType commandType(byte type) { private MessageType commandType(byte type) {
for (CommandType ct : CommandType.values()) { for (MessageType ct : MessageType.values()) {
if (ct.ordinal() == type) { if (ct.ordinal() == type) {
return ct; return ct;
} }
@ -119,7 +119,7 @@ public class NettyDecoder extends ReplayingDecoder<NettyDecoder.State> {
* @param magic magic * @param magic magic
*/ */
private void checkMagic(byte magic) { private void checkMagic(byte magic) {
if (magic != Command.MAGIC) { if (magic != Message.MAGIC) {
throw new IllegalArgumentException("illegal packet [magic]" + magic); throw new IllegalArgumentException("illegal packet [magic]" + magic);
} }
} }
@ -128,7 +128,7 @@ public class NettyDecoder extends ReplayingDecoder<NettyDecoder.State> {
* check version * check version
*/ */
private void checkVersion(byte version) { private void checkVersion(byte version) {
if (version != Command.VERSION) { if (version != Message.VERSION) {
throw new IllegalArgumentException("illegal protocol [version]" + version); throw new IllegalArgumentException("illegal protocol [version]" + version);
} }
} }

12
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/codec/NettyEncoder.java

@ -17,7 +17,7 @@
package org.apache.dolphinscheduler.remote.codec; package org.apache.dolphinscheduler.remote.codec;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException; import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -29,7 +29,7 @@ import io.netty.handler.codec.MessageToByteEncoder;
* netty encoder * netty encoder
*/ */
@Sharable @Sharable
public class NettyEncoder extends MessageToByteEncoder<Command> { public class NettyEncoder extends MessageToByteEncoder<Message> {
/** /**
* encode * encode
@ -39,12 +39,12 @@ public class NettyEncoder extends MessageToByteEncoder<Command> {
* @param out byte buffer * @param out byte buffer
*/ */
@Override @Override
protected void encode(ChannelHandlerContext ctx, Command msg, ByteBuf out) throws Exception { protected void encode(ChannelHandlerContext ctx, Message msg, ByteBuf out) throws Exception {
if (msg == null) { if (msg == null) {
throw new RemotingException("encode msg is null"); throw new RemotingException("encode msg is null");
} }
out.writeByte(Command.MAGIC); out.writeByte(Message.MAGIC);
out.writeByte(Command.VERSION); out.writeByte(Message.VERSION);
out.writeByte(msg.getType().ordinal()); out.writeByte(msg.getType().ordinal());
out.writeLong(msg.getOpaque()); out.writeLong(msg.getOpaque());
writeContext(msg, out); writeContext(msg, out);
@ -52,7 +52,7 @@ public class NettyEncoder extends MessageToByteEncoder<Command> {
out.writeBytes(msg.getBody()); out.writeBytes(msg.getBody());
} }
private void writeContext(Command msg, ByteBuf out) { private void writeContext(Message msg, ByteBuf out) {
byte[] headerBytes = msg.getContext().toBytes(); byte[] headerBytes = msg.getContext().toBytes();
out.writeInt(headerBytes.length); out.writeInt(headerBytes.length);
out.writeBytes(headerBytes); out.writeBytes(headerBytes);

4
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/BaseCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/BaseMessage.java

@ -33,7 +33,7 @@ import lombok.NoArgsConstructor;
*/ */
@Data @Data
@NoArgsConstructor @NoArgsConstructor
public abstract class BaseCommand implements Serializable { public abstract class BaseMessage implements Serializable, RequestMessageBuilder {
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
@ -49,7 +49,7 @@ public abstract class BaseCommand implements Serializable {
protected long messageSendTime; protected long messageSendTime;
protected BaseCommand(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) { protected BaseMessage(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) {
this.messageSenderAddress = messageSenderAddress; this.messageSenderAddress = messageSenderAddress;
this.messageReceiverAddress = messageReceiverAddress; this.messageReceiverAddress = messageReceiverAddress;
this.messageSendTime = messageSendTime; this.messageSendTime = messageSendTime;

67
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CacheExpireCommand.java

@ -1,67 +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.remote.command;
import org.apache.dolphinscheduler.common.enums.CacheType;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import java.io.Serializable;
/**
* db task ack request command
*/
public class CacheExpireCommand implements Serializable {
private CacheType cacheType;
private String cacheKey;
public CacheExpireCommand() {
super();
}
public CacheExpireCommand(CacheType cacheType, String cacheKey) {
this.cacheType = cacheType;
this.cacheKey = cacheKey;
}
public CacheType getCacheType() {
return cacheType;
}
public String getCacheKey() {
return cacheKey;
}
/**
* package command
*
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.CACHE_EXPIRE);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
}
@Override
public String toString() {
return String.format("CacheExpireCommand{CacheType=%s, cacheKey=%s}", cacheType, cacheKey);
}
}

20
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/Command.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/Message.java

@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicLong;
* receive task log request command and content fill * receive task log request command and content fill
* for netty data serializable transfer * for netty data serializable transfer
*/ */
public class Command implements Serializable { public class Message implements Serializable {
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
@ -33,18 +33,18 @@ public class Command implements Serializable {
public static final byte MAGIC = (byte) 0xbabe; public static final byte MAGIC = (byte) 0xbabe;
public static final byte VERSION = 0; public static final byte VERSION = 0;
public Command() { public Message() {
this.opaque = REQUEST_ID.getAndIncrement(); this.opaque = REQUEST_ID.getAndIncrement();
} }
public Command(long opaque) { public Message(long opaque) {
this.opaque = opaque; this.opaque = opaque;
} }
/** /**
* command type * command type
*/ */
private CommandType type; private MessageType type;
/** /**
* request unique identification * request unique identification
@ -54,18 +54,18 @@ public class Command implements Serializable {
/** /**
* request context * request context
*/ */
private CommandContext context = new CommandContext(); private MessageContext context = new MessageContext();
/** /**
* data body * data body
*/ */
private byte[] body; private byte[] body;
public CommandType getType() { public MessageType getType() {
return type; return type;
} }
public void setType(CommandType type) { public void setType(MessageType type) {
this.type = type; this.type = type;
} }
@ -85,11 +85,11 @@ public class Command implements Serializable {
this.body = body; this.body = body;
} }
public CommandContext getContext() { public MessageContext getContext() {
return context; return context;
} }
public void setContext(CommandContext context) { public void setContext(MessageContext context) {
this.context = context; this.context = context;
} }
@ -112,7 +112,7 @@ public class Command implements Serializable {
if (getClass() != obj.getClass()) { if (getClass() != obj.getClass()) {
return false; return false;
} }
Command other = (Command) obj; Message other = (Message) obj;
return opaque == other.opaque; return opaque == other.opaque;
} }

6
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CommandContext.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/MessageContext.java

@ -26,7 +26,7 @@ import java.util.Map;
/** /**
* command context * command context
*/ */
public class CommandContext implements Serializable { public class MessageContext implements Serializable {
private Map<String, String> items = new LinkedHashMap<>(); private Map<String, String> items = new LinkedHashMap<>();
@ -50,7 +50,7 @@ public class CommandContext implements Serializable {
return JSONUtils.toJsonByteArray(this); return JSONUtils.toJsonByteArray(this);
} }
public static CommandContext valueOf(byte[] src) { public static MessageContext valueOf(byte[] src) {
return JSONUtils.parseObject(src, CommandContext.class); return JSONUtils.parseObject(src, MessageContext.class);
} }
} }

2
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CommandHeader.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/MessageHeader.java

@ -25,7 +25,7 @@ import lombok.Data;
* command header * command header
*/ */
@Data @Data
public class CommandHeader implements Serializable { public class MessageHeader implements Serializable {
/** /**
* type * type

18
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CommandType.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/MessageType.java

@ -17,7 +17,7 @@
package org.apache.dolphinscheduler.remote.command; package org.apache.dolphinscheduler.remote.command;
public enum CommandType { public enum MessageType {
GET_APP_ID_REQUEST, GET_APP_ID_REQUEST,
GET_APP_ID_RESPONSE, GET_APP_ID_RESPONSE,
@ -49,27 +49,27 @@ public enum CommandType {
/** /**
* dispatch task request * dispatch task request
*/ */
TASK_DISPATCH_REQUEST, TASK_DISPATCH_MESSAGE,
/** /**
* task execute running, from worker to master * task execute running, from worker to master
*/ */
TASK_EXECUTE_RUNNING, TASK_EXECUTE_RUNNING_MESSAGE,
/** /**
* task execute running ack, from master to worker * task execute running ack, from master to worker
*/ */
TASK_EXECUTE_RUNNING_ACK, TASK_EXECUTE_RUNNING_MESSAGE_ACK,
/** /**
* task execute response, from worker to master * task execute response, from worker to master
*/ */
TASK_EXECUTE_RESULT, TASK_EXECUTE_RESULT_MESSAGE,
/** /**
* task execute response ack, from master to worker * task execute response ack, from master to worker
*/ */
TASK_EXECUTE_RESULT_ACK, TASK_EXECUTE_RESULT_MESSAGE_ACK,
TASK_KILL_REQUEST, TASK_KILL_REQUEST,
@ -77,7 +77,7 @@ public enum CommandType {
TASK_REJECT, TASK_REJECT,
TASK_REJECT_ACK, TASK_REJECT_MESSAGE_ACK,
/** /**
* task savepoint, for stream task * task savepoint, for stream task
@ -127,12 +127,12 @@ public enum CommandType {
/** /**
* update taskInstance's PID request * update taskInstance's PID request
*/ */
TASK_UPDATE_PID, TASK_UPDATE_PID_MESSAGE,
/** /**
* update taskInstance's PID response ack, from master to worker * update taskInstance's PID response ack, from master to worker
*/ */
TASK_UPDATE_PID_ACK, TASK_UPDATE_PID__MESSAGE_ACK,
/** /**
* workflow executing data response, from master to api * workflow executing data response, from master to api

27
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/WorkflowMetricsCleanUpCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/RequestMessageBuilder.java

@ -17,28 +17,19 @@
package org.apache.dolphinscheduler.remote.command; package org.apache.dolphinscheduler.remote.command;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.utils.JsonSerializer;
import java.io.Serializable; import java.io.Serializable;
import lombok.Data; public interface RequestMessageBuilder extends Serializable {
@Data default Message convert2Command() {
public class WorkflowMetricsCleanUpCommand implements Serializable { Message message = new Message();
message.setType(getCommandType());
private String processDefinitionCode; byte[] body = JsonSerializer.serialize(this);
message.setBody(body);
/** return message;
* package request command
*
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.WORKFLOW_METRICS_CLEANUP);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
MessageType getCommandType();
} }

35
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/ResponseMessageBuilder.java

@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.remote.command;
import org.apache.dolphinscheduler.remote.utils.JsonSerializer;
import java.io.Serializable;
public interface ResponseMessageBuilder extends Serializable {
default Message convert2Command(long opaque) {
Message message = new Message(opaque);
message.setType(getCommandType());
byte[] body = JsonSerializer.serialize(this);
message.setBody(body);
return message;
}
MessageType getCommandType();
}

18
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/StateEventResponse.java

@ -15,21 +15,23 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.remote.command.alert; package org.apache.dolphinscheduler.remote.command;
import java.io.Serializable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/**
* db task final result response command
*/
@Data @Data
@NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class AlertSendResponseResult implements Serializable { public class StateEventResponse implements RequestMessageBuilder {
private boolean success; private String key;
private String message; @Override
public MessageType getCommandType() {
return MessageType.TASK_EXECUTE_RESULT_MESSAGE_ACK;
}
} }

49
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/StateEventResponseCommand.java

@ -1,49 +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.remote.command;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* db task final result response command
*/
@Data
@AllArgsConstructor
public class StateEventResponseCommand implements Serializable {
private String key;
/**
* package response command
*
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.TASK_EXECUTE_RESULT_ACK);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
}
}

42
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskStateEventResponseCommand.java

@ -1,42 +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.remote.command;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import java.io.Serializable;
public class TaskStateEventResponseCommand implements Serializable {
private TaskExecutionStatus status;
private String key;
/**
* package response command
*
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.TASK_EXECUTE_RESULT_ACK);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
}
}

23
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendRequestCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendRequest.java

@ -17,11 +17,8 @@
package org.apache.dolphinscheduler.remote.command.alert; package org.apache.dolphinscheduler.remote.command.alert;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import org.apache.dolphinscheduler.remote.utils.JsonSerializer;
import java.io.Serializable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -30,7 +27,7 @@ import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class AlertSendRequestCommand implements Serializable { public class AlertSendRequest implements RequestMessageBuilder {
private int groupId; private int groupId;
@ -40,16 +37,8 @@ public class AlertSendRequestCommand implements Serializable {
private int warnType; private int warnType;
/** @Override
* package request command public MessageType getCommandType() {
* return MessageType.ALERT_SEND_REQUEST;
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.ALERT_SEND_REQUEST);
byte[] body = JsonSerializer.serialize(this);
command.setBody(body);
return command;
} }
} }

33
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponse.java

@ -17,9 +17,8 @@
package org.apache.dolphinscheduler.remote.command.alert; package org.apache.dolphinscheduler.remote.command.alert;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.ResponseMessageBuilder;
import org.apache.dolphinscheduler.remote.utils.JsonSerializer;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
@ -31,7 +30,7 @@ import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class AlertSendResponseCommand implements Serializable { public class AlertSendResponse implements ResponseMessageBuilder {
/** /**
* true:All alert are successful, * true:All alert are successful,
@ -41,17 +40,19 @@ public class AlertSendResponseCommand implements Serializable {
private List<AlertSendResponseResult> resResults; private List<AlertSendResponseResult> resResults;
/** @Override
* package response command public MessageType getCommandType() {
* return MessageType.ALERT_SEND_RESPONSE;
* @param opaque request unique identification }
* @return command
*/ @Data
public Command convert2Command(long opaque) { @NoArgsConstructor
Command command = new Command(opaque); @AllArgsConstructor
command.setType(CommandType.ALERT_SEND_RESPONSE); public static class AlertSendResponseResult implements Serializable {
byte[] body = JsonSerializer.serialize(this);
command.setBody(body); private boolean success;
return command;
private String message;
} }
} }

41
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/cache/CacheExpireRequest.java vendored

@ -0,0 +1,41 @@
/*
* 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.remote.command.cache;
import org.apache.dolphinscheduler.common.enums.CacheType;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CacheExpireRequest implements RequestMessageBuilder {
private CacheType cacheType;
private String cacheKey;
@Override
public MessageType getCommandType() {
return MessageType.CACHE_EXPIRE;
}
}

18
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetAppIdRequestCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetAppIdRequest.java

@ -17,11 +17,8 @@
package org.apache.dolphinscheduler.remote.command.log; package org.apache.dolphinscheduler.remote.command.log;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import org.apache.dolphinscheduler.remote.command.CommandType;
import java.io.Serializable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -30,18 +27,15 @@ import lombok.NoArgsConstructor;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class GetAppIdRequestCommand implements Serializable { public class GetAppIdRequest implements RequestMessageBuilder {
private String logPath; private String logPath;
private String appInfoPath; private String appInfoPath;
public Command convert2Command() { @Override
Command command = new Command(); public MessageType getCommandType() {
command.setType(CommandType.GET_APP_ID_REQUEST); return MessageType.GET_APP_ID_REQUEST;
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

17
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetAppIdResponseCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetAppIdResponse.java

@ -17,11 +17,9 @@
package org.apache.dolphinscheduler.remote.command.log; package org.apache.dolphinscheduler.remote.command.log;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.ResponseMessageBuilder;
import org.apache.dolphinscheduler.remote.command.CommandType;
import java.io.Serializable;
import java.util.List; import java.util.List;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -31,15 +29,12 @@ import lombok.NoArgsConstructor;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class GetAppIdResponseCommand implements Serializable { public class GetAppIdResponse implements ResponseMessageBuilder {
private List<String> appIds; private List<String> appIds;
public Command convert2Command(long opaque) { @Override
Command command = new Command(opaque); public MessageType getCommandType() {
command.setType(CommandType.GET_APP_ID_RESPONSE); return MessageType.GET_APP_ID_RESPONSE;
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

44
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesRequest.java

@ -0,0 +1,44 @@
/*
* 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.remote.command.log;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* get log bytes request command
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class GetLogBytesRequest implements RequestMessageBuilder {
/**
* log path
*/
private String path;
@Override
public MessageType getCommandType() {
return MessageType.GET_LOG_BYTES_REQUEST;
}
}

55
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesRequestCommand.java

@ -1,55 +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.remote.command.log;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* get log bytes request command
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class GetLogBytesRequestCommand implements Serializable {
/**
* log path
*/
private String path;
/**
* package request command
*
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.GET_LOG_BYTES_REQUEST);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
}
}

45
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponse.java

@ -0,0 +1,45 @@
/*
* 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.remote.command.log;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.ResponseMessageBuilder;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* get log bytes response command
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class GetLogBytesResponse implements ResponseMessageBuilder {
/**
* log byte data
*/
private byte[] data;
@Override
public MessageType getCommandType() {
return MessageType.GET_LOG_BYTES_RESPONSE;
}
}

57
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponseCommand.java

@ -1,57 +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.remote.command.log;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* get log bytes response command
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class GetLogBytesResponseCommand implements Serializable {
/**
* log byte data
*/
private byte[] data;
/**
* package response command
*
* @param opaque request unique identification
* @return command
*/
public Command convert2Command(long opaque) {
Command command = new Command(opaque);
command.setType(CommandType.GET_LOG_BYTES_RESPONSE);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
}
}

23
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogRequestCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogRequest.java

@ -17,11 +17,8 @@
package org.apache.dolphinscheduler.remote.command.log; package org.apache.dolphinscheduler.remote.command.log;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import org.apache.dolphinscheduler.remote.command.CommandType;
import java.io.Serializable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -33,23 +30,15 @@ import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class RemoveTaskLogRequestCommand implements Serializable { public class RemoveTaskLogRequest implements RequestMessageBuilder {
/** /**
* log path * log path
*/ */
private String path; private String path;
/** @Override
* package request command public MessageType getCommandType() {
* return MessageType.REMOVE_TAK_LOG_REQUEST;
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.REMOVE_TAK_LOG_REQUEST);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

23
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogResponseCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogResponse.java

@ -17,11 +17,8 @@
package org.apache.dolphinscheduler.remote.command.log; package org.apache.dolphinscheduler.remote.command.log;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.ResponseMessageBuilder;
import org.apache.dolphinscheduler.remote.command.CommandType;
import java.io.Serializable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -33,23 +30,15 @@ import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class RemoveTaskLogResponseCommand implements Serializable { public class RemoveTaskLogResponse implements ResponseMessageBuilder {
/* /*
* TaskPriorityQueueConsumer.* log path * TaskPriorityQueueConsumer.* log path
*/ */
private Boolean status; private Boolean status;
/** @Override
* package request command public MessageType getCommandType() {
* return MessageType.REMOVE_TAK_LOG_RESPONSE;
* @return command
*/
public Command convert2Command(long opaque) {
Command command = new Command(opaque);
command.setType(CommandType.REMOVE_TAK_LOG_RESPONSE);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

23
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogRequestCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogRequest.java

@ -17,11 +17,8 @@
package org.apache.dolphinscheduler.remote.command.log; package org.apache.dolphinscheduler.remote.command.log;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import org.apache.dolphinscheduler.remote.command.CommandType;
import java.io.Serializable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -33,7 +30,7 @@ import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class RollViewLogRequestCommand implements Serializable { public class RollViewLogRequest implements RequestMessageBuilder {
/** /**
* log path * log path
@ -50,16 +47,8 @@ public class RollViewLogRequestCommand implements Serializable {
*/ */
private int limit; private int limit;
/** @Override
* package request command public MessageType getCommandType() {
* return MessageType.ROLL_VIEW_LOG_REQUEST;
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.ROLL_VIEW_LOG_REQUEST);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

24
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogResponseCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogResponse.java

@ -17,11 +17,8 @@
package org.apache.dolphinscheduler.remote.command.log; package org.apache.dolphinscheduler.remote.command.log;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.ResponseMessageBuilder;
import org.apache.dolphinscheduler.remote.command.CommandType;
import java.io.Serializable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -33,24 +30,15 @@ import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class RollViewLogResponseCommand implements Serializable { public class RollViewLogResponse implements ResponseMessageBuilder {
/** /**
* response data * response data
*/ */
private String msg; private String msg;
/** @Override
* package response command public MessageType getCommandType() {
* return MessageType.ROLL_VIEW_LOG_RESPONSE;
* @param opaque request unique identification
* @return command
*/
public Command convert2Command(long opaque) {
Command command = new Command(opaque);
command.setType(CommandType.ROLL_VIEW_LOG_RESPONSE);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

23
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/ViewLogRequestCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/ViewLogRequest.java

@ -17,11 +17,8 @@
package org.apache.dolphinscheduler.remote.command.log; package org.apache.dolphinscheduler.remote.command.log;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import org.apache.dolphinscheduler.remote.command.CommandType;
import java.io.Serializable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -33,23 +30,15 @@ import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class ViewLogRequestCommand implements Serializable { public class ViewLogRequest implements RequestMessageBuilder {
/** /**
* log path * log path
*/ */
private String path; private String path;
/** @Override
* package request command public MessageType getCommandType() {
* return MessageType.VIEW_WHOLE_LOG_REQUEST;
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.VIEW_WHOLE_LOG_REQUEST);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

56
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/ViewLogResponseCommand.java

@ -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.remote.command.log;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* view log response command
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ViewLogResponseCommand implements Serializable {
/**
* response data
*/
private String msg;
/**
* package response command
*
* @param opaque request unique identification
* @return command
*/
public Command convert2Command(long opaque) {
Command command = new Command(opaque);
command.setType(CommandType.VIEW_WHOLE_LOG_RESPONSE);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
}
}

44
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/ViewLogResponseResponse.java

@ -0,0 +1,44 @@
/*
* 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.remote.command.log;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.ResponseMessageBuilder;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* view log response command
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ViewLogResponseResponse implements ResponseMessageBuilder {
/**
* response data
*/
private String msg;
@Override
public MessageType getCommandType() {
return MessageType.VIEW_WHOLE_LOG_RESPONSE;
}
}

18
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskDispatchCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskDispatchMessage.java

@ -15,10 +15,11 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.remote.command; package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
import org.apache.dolphinscheduler.remote.command.BaseMessage;
import org.apache.dolphinscheduler.remote.command.MessageType;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -32,13 +33,13 @@ import lombok.ToString;
@NoArgsConstructor @NoArgsConstructor
@ToString(callSuper = true) @ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class TaskDispatchCommand extends BaseCommand { public class TaskDispatchMessage extends BaseMessage {
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
private TaskExecutionContext taskExecutionContext; private TaskExecutionContext taskExecutionContext;
public TaskDispatchCommand(TaskExecutionContext taskExecutionContext, public TaskDispatchMessage(TaskExecutionContext taskExecutionContext,
String messageSenderAddress, String messageSenderAddress,
String messageReceiverAddress, String messageReceiverAddress,
long messageSendTime) { long messageSendTime) {
@ -46,12 +47,9 @@ public class TaskDispatchCommand extends BaseCommand {
this.taskExecutionContext = taskExecutionContext; this.taskExecutionContext = taskExecutionContext;
} }
public Command convert2Command() { @Override
Command command = new Command(); public MessageType getCommandType() {
command.setType(CommandType.TASK_DISPATCH_REQUEST); return MessageType.TASK_DISPATCH_MESSAGE;
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

23
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteResultCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteResultMessage.java

@ -15,9 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.remote.command; package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.BaseMessage;
import org.apache.dolphinscheduler.remote.command.MessageType;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -31,9 +32,9 @@ import lombok.ToString;
@NoArgsConstructor @NoArgsConstructor
@ToString(callSuper = true) @ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class TaskExecuteResultCommand extends BaseCommand { public class TaskExecuteResultMessage extends BaseMessage {
public TaskExecuteResultCommand(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) { public TaskExecuteResultMessage(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) {
super(messageSenderAddress, messageReceiverAddress, messageSendTime); super(messageSenderAddress, messageReceiverAddress, messageSendTime);
} }
@ -92,16 +93,8 @@ public class TaskExecuteResultCommand extends BaseCommand {
*/ */
private String varPool; private String varPool;
/** @Override
* package response command public MessageType getCommandType() {
* return MessageType.TASK_EXECUTE_RESULT_MESSAGE;
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.TASK_EXECUTE_RESULT);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

23
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteAckCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteResultMessageAck.java

@ -15,9 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.remote.command; package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.BaseMessage;
import org.apache.dolphinscheduler.remote.command.MessageType;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -32,12 +33,12 @@ import lombok.ToString;
@NoArgsConstructor @NoArgsConstructor
@ToString(callSuper = true) @ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class TaskExecuteAckCommand extends BaseCommand { public class TaskExecuteResultMessageAck extends BaseMessage {
private int taskInstanceId; private int taskInstanceId;
private boolean success; private boolean success;
public TaskExecuteAckCommand(boolean success, public TaskExecuteResultMessageAck(boolean success,
int taskInstanceId, int taskInstanceId,
String sourceServerAddress, String sourceServerAddress,
String messageReceiverAddress, String messageReceiverAddress,
@ -47,16 +48,8 @@ public class TaskExecuteAckCommand extends BaseCommand {
this.taskInstanceId = taskInstanceId; this.taskInstanceId = taskInstanceId;
} }
/** @Override
* package response command public MessageType getCommandType() {
* return MessageType.TASK_EXECUTE_RESULT_MESSAGE_ACK;
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.TASK_EXECUTE_RESULT_ACK);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

23
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteRunningCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteRunningMessage.java

@ -15,10 +15,11 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.remote.command; package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.remote.command.BaseMessage;
import org.apache.dolphinscheduler.remote.command.MessageType;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -32,7 +33,7 @@ import lombok.ToString;
@NoArgsConstructor @NoArgsConstructor
@ToString(callSuper = true) @ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class TaskExecuteRunningCommand extends BaseCommand { public class TaskExecuteRunningMessage extends BaseMessage {
/** /**
* taskInstanceId * taskInstanceId
@ -79,21 +80,13 @@ public class TaskExecuteRunningCommand extends BaseCommand {
*/ */
private String appIds; private String appIds;
public TaskExecuteRunningCommand(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) { public TaskExecuteRunningMessage(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) {
super(messageSenderAddress, messageReceiverAddress, messageSendTime); super(messageSenderAddress, messageReceiverAddress, messageSendTime);
} }
/** @Override
* package request command public MessageType getCommandType() {
* return MessageType.TASK_EXECUTE_RUNNING_MESSAGE;
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.TASK_EXECUTE_RUNNING);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

56
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteRunningMessageAck.java

@ -0,0 +1,56 @@
/*
* 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.remote.command.task;
import org.apache.dolphinscheduler.remote.command.BaseMessage;
import org.apache.dolphinscheduler.remote.command.MessageType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* task execute running ack command
* from master to worker
*/
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class TaskExecuteRunningMessageAck extends BaseMessage {
private boolean success;
private int taskInstanceId;
public TaskExecuteRunningMessageAck(boolean success,
int taskInstanceId,
String messageSenderAddress,
String messageReceiverAddress,
long messageSendTime) {
super(messageSenderAddress, messageReceiverAddress, messageSendTime);
this.success = success;
this.taskInstanceId = taskInstanceId;
}
@Override
public MessageType getCommandType() {
return MessageType.TASK_EXECUTE_RUNNING_MESSAGE_ACK;
}
}

23
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteStartCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteStartMessage.java

@ -15,9 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.remote.command; package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.BaseMessage;
import org.apache.dolphinscheduler.remote.command.MessageType;
import java.util.Map; import java.util.Map;
@ -33,7 +34,7 @@ import lombok.ToString;
@NoArgsConstructor @NoArgsConstructor
@ToString(callSuper = true) @ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class TaskExecuteStartCommand extends BaseCommand { public class TaskExecuteStartMessage extends BaseMessage {
private int executorId; private int executorId;
@ -57,21 +58,13 @@ public class TaskExecuteStartCommand extends BaseCommand {
private int dryRun; private int dryRun;
public TaskExecuteStartCommand(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) { public TaskExecuteStartMessage(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) {
super(messageSenderAddress, messageReceiverAddress, messageSendTime); super(messageSenderAddress, messageReceiverAddress, messageSendTime);
} }
/** @Override
* package request command public MessageType getCommandType() {
* return MessageType.TASK_EXECUTE_START;
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.TASK_EXECUTE_START);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

35
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskEventChangeCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskForceStartRequest.java

@ -15,21 +15,19 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.remote.command; package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/**
* db task final result response command
*/
@Data @Data
@NoArgsConstructor @NoArgsConstructor
public class TaskEventChangeCommand implements Serializable { @AllArgsConstructor
public class TaskForceStartRequest implements RequestMessageBuilder {
private String key; private String key;
@ -37,28 +35,17 @@ public class TaskEventChangeCommand implements Serializable {
private int taskInstanceId; private int taskInstanceId;
public TaskEventChangeCommand( public TaskForceStartRequest(
int processInstanceId, int processInstanceId,
int taskInstanceId) { int taskInstanceId) {
this.key = String.format("%d-%d", this.key = String.format("%d-%d", processInstanceId, taskInstanceId);
processInstanceId,
taskInstanceId);
this.processInstanceId = processInstanceId; this.processInstanceId = processInstanceId;
this.taskInstanceId = taskInstanceId; this.taskInstanceId = taskInstanceId;
} }
/** @Override
* package response command public MessageType getCommandType() {
* return MessageType.TASK_FORCE_STATE_EVENT_REQUEST;
* @return command
*/
public Command convert2Command(CommandType commandType) {
Command command = new Command();
command.setType(commandType);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

23
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskKillRequestCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskKillRequest.java

@ -15,11 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.remote.command; package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import java.io.Serializable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -31,23 +30,15 @@ import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class TaskKillRequestCommand implements Serializable { public class TaskKillRequest implements RequestMessageBuilder {
/** /**
* task id * task id
*/ */
private int taskInstanceId; private int taskInstanceId;
/** @Override
* package request command public MessageType getCommandType() {
* return MessageType.TASK_KILL_REQUEST;
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.TASK_KILL_REQUEST);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

23
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskKillResponseCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskKillResponse.java

@ -15,12 +15,12 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.remote.command; package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.ResponseMessageBuilder;
import java.io.Serializable;
import java.util.List; import java.util.List;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -35,7 +35,7 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class TaskKillResponseCommand implements Serializable { public class TaskKillResponse implements ResponseMessageBuilder {
private int taskInstanceId; private int taskInstanceId;
@ -50,17 +50,8 @@ public class TaskKillResponseCommand implements Serializable {
*/ */
private List<String> appIds; private List<String> appIds;
/** @Override
* package request command public MessageType getCommandType() {
* return MessageType.TASK_KILL_RESPONSE;
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.TASK_KILL_RESPONSE);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

23
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskRejectCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskRejectMessage.java

@ -15,9 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.remote.command; package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.BaseMessage;
import org.apache.dolphinscheduler.remote.command.MessageType;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -31,7 +32,7 @@ import lombok.ToString;
@NoArgsConstructor @NoArgsConstructor
@ToString(callSuper = true) @ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class TaskRejectCommand extends BaseCommand { public class TaskRejectMessage extends BaseMessage {
/** /**
* taskInstanceId * taskInstanceId
@ -48,20 +49,12 @@ public class TaskRejectCommand extends BaseCommand {
*/ */
private int processInstanceId; private int processInstanceId;
public TaskRejectCommand(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) { public TaskRejectMessage(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) {
super(messageSenderAddress, messageReceiverAddress, messageSendTime); super(messageSenderAddress, messageReceiverAddress, messageSendTime);
} }
/** @Override
* package request command public MessageType getCommandType() {
* return MessageType.TASK_REJECT;
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.TASK_REJECT);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

23
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskRejectAckCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskRejectMessageAck.java

@ -15,9 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.remote.command; package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.BaseMessage;
import org.apache.dolphinscheduler.remote.command.MessageType;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -28,12 +29,12 @@ import lombok.ToString;
@NoArgsConstructor @NoArgsConstructor
@ToString(callSuper = true) @ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class TaskRejectAckCommand extends BaseCommand { public class TaskRejectMessageAck extends BaseMessage {
private int taskInstanceId; private int taskInstanceId;
private boolean success; private boolean success;
public TaskRejectAckCommand(boolean success, public TaskRejectMessageAck(boolean success,
int taskInstanceId, int taskInstanceId,
String messageSenderAddress, String messageSenderAddress,
String messageReceiverAddress, String messageReceiverAddress,
@ -43,17 +44,9 @@ public class TaskRejectAckCommand extends BaseCommand {
this.taskInstanceId = taskInstanceId; this.taskInstanceId = taskInstanceId;
} }
/** @Override
* package response command public MessageType getCommandType() {
* return MessageType.TASK_REJECT_MESSAGE_ACK;
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.TASK_REJECT_ACK);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

23
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskSavePointRequestCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskSavePointRequest.java

@ -15,11 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.remote.command; package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import java.io.Serializable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -31,23 +30,15 @@ import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class TaskSavePointRequestCommand implements Serializable { public class TaskSavePointRequest implements RequestMessageBuilder {
/** /**
* task id * task id
*/ */
private int taskInstanceId; private int taskInstanceId;
/** @Override
* package request command public MessageType getCommandType() {
* return MessageType.TASK_SAVEPOINT_REQUEST;
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.TASK_SAVEPOINT_REQUEST);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

23
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskSavePointResponseCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskSavePointResponse.java

@ -15,11 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.remote.command; package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import java.io.Serializable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -31,23 +30,15 @@ import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class TaskSavePointResponseCommand implements Serializable { public class TaskSavePointResponse implements RequestMessageBuilder {
/** /**
* taskInstanceId * taskInstanceId
*/ */
private int taskInstanceId; private int taskInstanceId;
/** @Override
* package request command public MessageType getCommandType() {
* return MessageType.TASK_SAVEPOINT_RESPONSE;
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.TASK_SAVEPOINT_RESPONSE);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

23
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskUpdatePidAckMessage.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskUpdatePidAckMessage.java

@ -15,11 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.remote.command; package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import java.io.Serializable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
@ -34,22 +33,14 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class TaskUpdatePidAckMessage implements Serializable { public class TaskUpdatePidAckMessage implements RequestMessageBuilder {
private boolean success; private boolean success;
private int taskInstanceId; private int taskInstanceId;
/** @Override
* package response command public MessageType getCommandType() {
* return MessageType.TASK_UPDATE_PID__MESSAGE_ACK;
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.TASK_UPDATE_PID_ACK);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

23
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskUpdatePidCommand.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskUpdatePidMessage.java

@ -15,9 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.remote.command; package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.BaseMessage;
import org.apache.dolphinscheduler.remote.command.MessageType;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -31,7 +32,7 @@ import lombok.ToString;
@NoArgsConstructor @NoArgsConstructor
@ToString(callSuper = true) @ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class TaskUpdatePidCommand extends BaseCommand { public class TaskUpdatePidMessage extends BaseMessage {
/** /**
* taskInstanceId * taskInstanceId
@ -63,21 +64,13 @@ public class TaskUpdatePidCommand extends BaseCommand {
*/ */
private int processId; private int processId;
public TaskUpdatePidCommand(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) { public TaskUpdatePidMessage(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) {
super(messageSenderAddress, messageReceiverAddress, messageSendTime); super(messageSenderAddress, messageReceiverAddress, messageSendTime);
} }
/** @Override
* package request command public MessageType getCommandType() {
* return MessageType.TASK_UPDATE_PID_MESSAGE;
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.TASK_UPDATE_PID);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
} }

44
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteRunningAckMessage.java → dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskWakeupRequest.java

@ -15,41 +15,37 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.remote.command; package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import java.io.Serializable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/**
* task execute running ack command
* from master to worker
*/
@Data @Data
@Builder
@AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class TaskExecuteRunningAckMessage implements Serializable { @AllArgsConstructor
public class TaskWakeupRequest implements RequestMessageBuilder {
private String key;
private int processInstanceId;
private boolean success;
private int taskInstanceId; private int taskInstanceId;
/** public TaskWakeupRequest(
* package response command int processInstanceId,
* int taskInstanceId) {
* @return command this.key = String.format("%d-%d", processInstanceId, taskInstanceId);
*/
public Command convert2Command() { this.processInstanceId = processInstanceId;
Command command = new Command(); this.taskInstanceId = taskInstanceId;
command.setType(CommandType.TASK_EXECUTE_RUNNING_ACK);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
} }
@Override
public MessageType getCommandType() {
return MessageType.TASK_WAKEUP_EVENT_REQUEST;
}
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save