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

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.AlertPluginInstance;
import org.apache.dolphinscheduler.dao.entity.AlertSendStatus;
import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponseCommand;
import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponseResult;
import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponse;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
@ -166,7 +165,7 @@ public final class AlertSenderService extends Thread {
* @param content content
* @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);
AlertData alertData = AlertData.builder()
.content(content)
@ -175,29 +174,32 @@ public final class AlertSenderService extends Thread {
.build();
boolean sendResponseStatus = true;
List<AlertSendResponseResult> sendResponseResults = new ArrayList<>();
List<AlertSendResponse.AlertSendResponseResult> sendResponseResults = new ArrayList<>();
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);
alertSendResponseResult.setSuccess(false);
alertSendResponseResult.setMessage(message);
sendResponseResults.add(alertSendResponseResult);
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) {
AlertResult alertResult = this.alertResultHandler(instance, alertData);
if (alertResult != null) {
AlertSendResponseResult alertSendResponseResult = new AlertSendResponseResult(
Boolean.parseBoolean(String.valueOf(alertResult.getStatus())), alertResult.getMessage());
AlertSendResponse.AlertSendResponseResult alertSendResponseResult =
new AlertSendResponse.AlertSendResponseResult(
Boolean.parseBoolean(String.valueOf(alertResult.getStatus())),
alertResult.getMessage());
sendResponseStatus = sendResponseStatus && alertSendResponseResult.isSuccess();
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.dao.PluginDao;
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.processor.NettyRequestProcessor;
import java.io.Closeable;
import java.util.List;
import javax.annotation.PreDestroy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.event.ApplicationReadyEvent;
@ -42,21 +44,16 @@ import org.springframework.context.event.EventListener;
@Slf4j
public class AlertServer implements Closeable {
private final PluginDao pluginDao;
private final AlertSenderService alertSenderService;
private final AlertRequestProcessor alertRequestProcessor;
private final AlertConfig alertConfig;
private NettyRemotingServer nettyRemotingServer;
@Autowired
private PluginDao pluginDao;
public AlertServer(PluginDao pluginDao,
AlertSenderService alertSenderService,
AlertRequestProcessor alertRequestProcessor,
AlertConfig alertConfig) {
this.pluginDao = pluginDao;
this.alertSenderService = alertSenderService;
this.alertRequestProcessor = alertRequestProcessor;
this.alertConfig = alertConfig;
}
@Autowired
private AlertSenderService alertSenderService;
@Autowired
private List<NettyRequestProcessor> nettyRequestProcessors;
@Autowired
private AlertConfig alertConfig;
private NettyRemotingServer nettyRemotingServer;
public static void main(String[] args) {
Thread.currentThread().setName(Constants.THREAD_NAME_ALERT_SERVER);
@ -116,7 +113,10 @@ public class AlertServer implements Closeable {
protected void startServer() {
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();
}
}

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.AlertPluginInstance;
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.List;
@ -79,10 +79,10 @@ public class AlertSenderServiceTest {
when(alertDao.listInstanceByAlertGroupId(alertGroupId)).thenReturn(null);
when(alertConfig.getWaitTimeout()).thenReturn(0);
AlertSendResponseCommand alertSendResponseCommand =
AlertSendResponse alertSendResponse =
alertSenderService.syncHandler(alertGroupId, title, content, WarningType.ALL.getCode());
Assertions.assertFalse(alertSendResponseCommand.isSuccess());
alertSendResponseCommand.getResResults().forEach(result -> logger
Assertions.assertFalse(alertSendResponse.isSuccess());
alertSendResponse.getResResults().forEach(result -> logger
.info("alert send response result, status:{}, message:{}", result.isSuccess(), result.getMessage()));
// 2.alert plugin does not exist
@ -100,10 +100,10 @@ public class AlertSenderServiceTest {
PluginDefine pluginDefine = new PluginDefine(pluginName, "1", null);
when(pluginDao.getPluginDefineById(pluginDefineId)).thenReturn(pluginDefine);
alertSendResponseCommand =
alertSendResponse =
alertSenderService.syncHandler(alertGroupId, title, content, WarningType.ALL.getCode());
Assertions.assertFalse(alertSendResponseCommand.isSuccess());
alertSendResponseCommand.getResResults().forEach(result -> logger
Assertions.assertFalse(alertSendResponse.isSuccess());
alertSendResponse.getResResults().forEach(result -> logger
.info("alert send response result, status:{}, message:{}", result.isSuccess(), result.getMessage()));
// 3.alert result value is null
@ -112,10 +112,10 @@ public class AlertSenderServiceTest {
when(alertPluginManager.getAlertChannel(1)).thenReturn(Optional.of(alertChannelMock));
when(alertConfig.getWaitTimeout()).thenReturn(0);
alertSendResponseCommand =
alertSendResponse =
alertSenderService.syncHandler(alertGroupId, title, content, WarningType.ALL.getCode());
Assertions.assertFalse(alertSendResponseCommand.isSuccess());
alertSendResponseCommand.getResResults().forEach(result -> logger
Assertions.assertFalse(alertSendResponse.isSuccess());
alertSendResponse.getResResults().forEach(result -> logger
.info("alert send response result, status:{}, message:{}", result.isSuccess(), result.getMessage()));
// 4.abnormal information inside the alert plug-in code
@ -125,10 +125,10 @@ public class AlertSenderServiceTest {
when(alertChannelMock.process(Mockito.any())).thenReturn(alertResult);
when(alertPluginManager.getAlertChannel(1)).thenReturn(Optional.of(alertChannelMock));
alertSendResponseCommand =
alertSendResponse =
alertSenderService.syncHandler(alertGroupId, title, content, WarningType.ALL.getCode());
Assertions.assertFalse(alertSendResponseCommand.isSuccess());
alertSendResponseCommand.getResResults().forEach(result -> logger
Assertions.assertFalse(alertSendResponse.isSuccess());
alertSendResponse.getResResults().forEach(result -> logger
.info("alert send response result, status:{}, message:{}", result.isSuccess(), result.getMessage()));
// 5.alert plugin send success
@ -139,10 +139,10 @@ public class AlertSenderServiceTest {
when(alertPluginManager.getAlertChannel(1)).thenReturn(Optional.of(alertChannelMock));
when(alertConfig.getWaitTimeout()).thenReturn(5000);
alertSendResponseCommand =
alertSendResponse =
alertSenderService.syncHandler(alertGroupId, title, content, WarningType.ALL.getCode());
Assertions.assertTrue(alertSendResponseCommand.isSuccess());
alertSendResponseCommand.getResResults().forEach(result -> logger
Assertions.assertTrue(alertSendResponse.isSuccess());
alertSendResponse.getResResults().forEach(result -> logger
.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;
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.impl.CacheKeyGenerator;
@ -96,7 +96,7 @@ public class CacheEvictAspect {
}
}
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.dao.entity.ProcessInstance;
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.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",
workflowInstance.getName()));
}
WorkflowStateEventChangeCommand workflowStateEventChangeCommand = new WorkflowStateEventChangeCommand(
WorkflowStateEventChangeRequest workflowStateEventChangeRequest = new WorkflowStateEventChangeRequest(
workflowInstance.getId(), 0, workflowInstance.getState(), workflowInstance.getId(), 0);
try {
apiRpcClient.send(Host.of(workflowInstance.getHost()), workflowStateEventChangeCommand.convert2Command());
apiRpcClient.send(Host.of(workflowInstance.getHost()), workflowStateEventChangeRequest.convert2Command());
} catch (RemotingException e) {
throw new ExecuteRuntimeException(
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.dao.entity.ProcessInstance;
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.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",
workflowInstance.getName());
// todo: Use specific stop command instead of WorkflowStateEventChangeCommand
WorkflowStateEventChangeCommand workflowStateEventChangeCommand = new WorkflowStateEventChangeCommand(
WorkflowStateEventChangeRequest workflowStateEventChangeRequest = new WorkflowStateEventChangeRequest(
workflowInstance.getId(), 0, workflowInstance.getState(), workflowInstance.getId(), 0);
try {
apiRpcClient.send(Host.of(workflowInstance.getHost()),
workflowStateEventChangeCommand.convert2Command());
workflowStateEventChangeRequest.convert2Command());
} catch (RemotingException e) {
throw new ExecuteRuntimeException(
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;
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.exceptions.RemotingException;
import org.apache.dolphinscheduler.remote.utils.Host;
@ -34,8 +34,8 @@ public class ApiRpcClient {
this.nettyRemotingClient = new NettyRemotingClient(new NettyClientConfig());
}
public void send(Host host, Command command) throws RemotingException {
nettyRemotingClient.send(host, command);
public void send(Host host, Message message) throws RemotingException {
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.repository.ProcessInstanceDao;
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
import org.apache.dolphinscheduler.remote.command.TaskExecuteStartCommand;
import org.apache.dolphinscheduler.remote.command.WorkflowExecutingDataRequestCommand;
import org.apache.dolphinscheduler.remote.command.WorkflowExecutingDataResponseCommand;
import org.apache.dolphinscheduler.remote.command.WorkflowStateEventChangeCommand;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.task.TaskExecuteStartMessage;
import org.apache.dolphinscheduler.remote.command.task.TaskForceStartRequest;
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.processor.StateEventCallbackService;
import org.apache.dolphinscheduler.remote.utils.Host;
@ -650,10 +652,10 @@ public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorServ
executionStatus.getDesc(), processInstance.getName());
// directly send the process instance state change event to target master, not guarantee the event send
// success
WorkflowStateEventChangeCommand workflowStateEventChangeCommand = new WorkflowStateEventChangeCommand(
WorkflowStateEventChangeRequest workflowStateEventChangeRequest = new WorkflowStateEventChangeRequest(
processInstance.getId(), 0, processInstance.getState(), processInstance.getId(), 0);
Host host = new Host(processInstance.getHost());
stateEventCallbackService.sendResult(host, workflowStateEventChangeCommand.convert2Command());
stateEventCallbackService.sendResult(host, workflowStateEventChangeRequest.convert2Command());
putMsg(result, Status.SUCCESS);
} else {
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());
processService.updateTaskGroupQueue(taskGroupQueue);
log.info("Sending force start command to master.");
processService.sendStartTask2Master(processInstance, taskGroupQueue.getTaskId(),
org.apache.dolphinscheduler.remote.command.CommandType.TASK_FORCE_STATE_EVENT_REQUEST);
log.info("Sending force start command to master: {}.", processInstance.getHost());
stateEventCallbackService.sendResult(
Host.of(processInstance.getHost()),
new TaskForceStartRequest(processInstance.getId(), taskGroupQueue.getTaskId()).convert2Command());
putMsg(result, Status.SUCCESS);
return result;
}
@ -1148,17 +1151,17 @@ public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorServ
return null;
}
Host host = new Host(processInstance.getHost());
WorkflowExecutingDataRequestCommand requestCommand = new WorkflowExecutingDataRequestCommand();
WorkflowExecutingDataRequest requestCommand = new WorkflowExecutingDataRequest();
requestCommand.setProcessInstanceId(processInstanceId);
org.apache.dolphinscheduler.remote.command.Command command =
Message message =
stateEventCallbackService.sendSync(host, requestCommand.convert2Command());
if (command == null) {
if (message == null) {
log.error("Query executing process instance from master error, processInstanceId:{}.",
processInstanceId);
return null;
}
WorkflowExecutingDataResponseCommand responseCommand =
JSONUtils.parseObject(command.getBody(), WorkflowExecutingDataResponseCommand.class);
WorkflowExecutingDataResponse responseCommand =
JSONUtils.parseObject(message.getBody(), WorkflowExecutingDataResponse.class);
return responseCommand.getWorkflowExecuteDto();
}
@ -1180,20 +1183,20 @@ public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorServ
List<Server> masterServerList = monitorService.getServerListFromRegistry(true);
Host host = new Host(masterServerList.get(0).getHost(), masterServerList.get(0).getPort());
TaskExecuteStartCommand taskExecuteStartCommand = new TaskExecuteStartCommand();
taskExecuteStartCommand.setExecutorId(loginUser.getId());
taskExecuteStartCommand.setExecutorName(loginUser.getUserName());
taskExecuteStartCommand.setProjectCode(projectCode);
taskExecuteStartCommand.setTaskDefinitionCode(taskDefinitionCode);
taskExecuteStartCommand.setTaskDefinitionVersion(taskDefinitionVersion);
taskExecuteStartCommand.setWorkerGroup(workerGroup);
taskExecuteStartCommand.setWarningGroupId(warningGroupId);
taskExecuteStartCommand.setEnvironmentCode(environmentCode);
taskExecuteStartCommand.setStartParams(startParams);
taskExecuteStartCommand.setDryRun(dryRun);
org.apache.dolphinscheduler.remote.command.Command response =
stateEventCallbackService.sendSync(host, taskExecuteStartCommand.convert2Command());
TaskExecuteStartMessage taskExecuteStartMessage = new TaskExecuteStartMessage();
taskExecuteStartMessage.setExecutorId(loginUser.getId());
taskExecuteStartMessage.setExecutorName(loginUser.getUserName());
taskExecuteStartMessage.setProjectCode(projectCode);
taskExecuteStartMessage.setTaskDefinitionCode(taskDefinitionCode);
taskExecuteStartMessage.setTaskDefinitionVersion(taskDefinitionVersion);
taskExecuteStartMessage.setWorkerGroup(workerGroup);
taskExecuteStartMessage.setWarningGroupId(warningGroupId);
taskExecuteStartMessage.setEnvironmentCode(environmentCode);
taskExecuteStartMessage.setStartParams(startParams);
taskExecuteStartMessage.setDryRun(dryRun);
Message response =
stateEventCallbackService.sendSync(host, taskExecuteStartMessage.convert2Command());
if (response != null) {
log.info("Send task execute start command complete, response is {}.", response);
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.model.Server;
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 java.util.List;
@ -44,13 +44,13 @@ public class MetricsCleanUpServiceImpl implements MetricsCleanUpService {
@Override
public void cleanUpWorkflowMetricsByDefinitionCode(String workflowDefinitionCode) {
WorkflowMetricsCleanUpCommand workflowMetricsCleanUpCommand = new WorkflowMetricsCleanUpCommand();
workflowMetricsCleanUpCommand.setProcessDefinitionCode(workflowDefinitionCode);
WorkflowMetricsCleanUpRequest workflowMetricsCleanUpRequest = new WorkflowMetricsCleanUpRequest();
workflowMetricsCleanUpRequest.setProcessDefinitionCode(workflowDefinitionCode);
List<Server> masterNodeList = registryClient.getServerList(NodeType.MASTER);
for (Server server : masterNodeList) {
try {
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) {
log.error(
"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.utils.TaskCacheUtils;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.remote.command.TaskKillRequestCommand;
import org.apache.dolphinscheduler.remote.command.TaskSavePointRequestCommand;
import org.apache.dolphinscheduler.remote.command.task.TaskKillRequest;
import org.apache.dolphinscheduler.remote.command.task.TaskSavePointRequest;
import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService;
import org.apache.dolphinscheduler.remote.utils.Host;
import org.apache.dolphinscheduler.service.log.LogClient;
@ -291,7 +291,7 @@ public class TaskInstanceServiceImpl extends BaseServiceImpl implements TaskInst
return result;
}
TaskSavePointRequestCommand command = new TaskSavePointRequestCommand(taskInstanceId);
TaskSavePointRequest command = new TaskSavePointRequest(taskInstanceId);
Host host = new Host(taskInstance.getHost());
stateEventCallbackService.sendResult(host, command.convert2Command());
@ -322,7 +322,7 @@ public class TaskInstanceServiceImpl extends BaseServiceImpl implements TaskInst
return result;
}
TaskKillRequestCommand command = new TaskKillRequestCommand(taskInstanceId);
TaskKillRequest command = new TaskKillRequest(taskInstanceId);
Host host = new Host(taskInstance.getHost());
stateEventCallbackService.sendResult(host, command.convert2Command());
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.TaskGroupQueueMapper;
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.process.ProcessService;
import org.apache.dolphinscheduler.service.process.TriggerRelationService;
@ -155,6 +156,9 @@ public class ExecuteFunctionServiceTest {
@Mock
private ProcessDefinitionService processDefinitionService;
@Mock
private StateEventCallbackService stateEventCallbackService;
private int processDefinitionId = 1;
private int processDefinitionVersion = 1;
@ -207,6 +211,7 @@ public class ExecuteFunctionServiceTest {
processInstance.setState(WorkflowExecutionStatus.FAILURE);
processInstance.setExecutorId(userId);
processInstance.setTenantId(tenantId);
processInstance.setHost("127.0.0.1:5678");
processInstance.setProcessDefinitionVersion(1);
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.task.api.TaskExecutionContext;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.TaskDispatchCommand;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.task.TaskDispatchMessage;
import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager;
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
import org.apache.dolphinscheduler.server.master.dispatch.ExecutorDispatcher;
@ -225,7 +225,7 @@ public class TaskPriorityQueueConsumer extends BaseDaemonThread {
.taskInstance(taskInstance)
.workerGroup(context.getWorkerGroup())
.executorType(ExecutorType.WORKER)
.command(toCommand(context))
.message(toCommand(context))
.build();
if (isTaskNeedToCheck(taskPriority)) {
@ -276,9 +276,9 @@ public class TaskPriorityQueueConsumer extends BaseDaemonThread {
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.
TaskDispatchCommand requestCommand = new TaskDispatchCommand(taskExecutionContext,
TaskDispatchMessage requestCommand = new TaskDispatchMessage(taskExecutionContext,
masterConfig.getMasterAddress(),
taskExecutionContext.getHost(),
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);
if (StringUtils.isEmpty(host.getAddress())) {
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");
}
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 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.server.master.dispatch.enums.ExecutorType;
@ -43,7 +43,7 @@ public class ExecutionContext {
/**
* command
*/
private Command command;
private Message message;
private TaskInstance taskInstance;
@ -54,12 +54,12 @@ public class ExecutionContext {
*/
private String workerGroup;
public ExecutionContext(Command command, ExecutorType executorType, TaskInstance taskInstance) {
this(command, executorType, DEFAULT_WORKER_GROUP, taskInstance);
public ExecutionContext(Message message, ExecutorType executorType, TaskInstance taskInstance) {
this(message, executorType, DEFAULT_WORKER_GROUP, taskInstance);
}
public ExecutionContext(Command command, ExecutorType executorType, String workerGroup, TaskInstance taskInstance) {
this.command = command;
public ExecutionContext(Message message, ExecutorType executorType, String workerGroup, TaskInstance taskInstance) {
this.message = message;
this.executorType = executorType;
this.workerGroup = workerGroup;
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.thread.ThreadUtils;
import org.apache.dolphinscheduler.remote.NettyRemotingClient;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.command.Message;
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.server.master.dispatch.context.ExecutionContext;
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.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.commons.collections4.CollectionUtils;
@ -37,6 +35,7 @@ import org.apache.commons.collections4.CollectionUtils;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.PostConstruct;
@ -60,10 +59,7 @@ public class NettyExecutorManager extends AbstractExecutorManager<Boolean> {
private ServerNodeManager serverNodeManager;
@Autowired
private TaskKillResponseProcessor taskKillResponseProcessor;
@Autowired
private TaskRecallProcessor taskRecallProcessor;
private List<NettyRequestProcessor> nettyRequestProcessors;
/**
* netty remote client
@ -80,8 +76,9 @@ public class NettyExecutorManager extends AbstractExecutorManager<Boolean> {
@PostConstruct
public void init() {
this.nettyRemotingClient.registerProcessor(CommandType.TASK_KILL_RESPONSE, taskKillResponseProcessor);
this.nettyRemotingClient.registerProcessor(CommandType.TASK_REJECT, taskRecallProcessor);
for (NettyRequestProcessor nettyRequestProcessor : nettyRequestProcessors) {
this.nettyRemotingClient.registerProcessor(nettyRequestProcessor);
}
}
/**
@ -98,12 +95,12 @@ public class NettyExecutorManager extends AbstractExecutorManager<Boolean> {
// fail nodes
Set<String> failNodeSet = new HashSet<>();
// build command accord executeContext
Command command = context.getCommand();
Message message = context.getMessage();
// execute task host
Host host = context.getHost();
for (int i = 0; i < allNodes.size(); i++) {
try {
doExecute(host, command);
doExecute(host, message);
context.setHost(host);
// We set the host to taskInstance to avoid when the worker down, this taskInstance may not be
// failovered, due to the taskInstance's host
@ -111,14 +108,14 @@ public class NettyExecutorManager extends AbstractExecutorManager<Boolean> {
context.getTaskInstance().setHost(host.getAddress());
return;
} catch (ExecuteException ex) {
log.error("Execute command {} error", command, ex);
log.error("Execute command {} error", message, ex);
try {
failNodeSet.add(host.getAddress());
Set<String> tmpAllIps = new HashSet<>(allNodes);
Collection<String> remained = CollectionUtils.subtract(tmpAllIps, failNodeSet);
if (CollectionUtils.isNotEmpty(remained)) {
host = Host.of(remained.iterator().next());
log.error("retry execute command : {} host : {}", command, host);
log.error("retry execute command : {} host : {}", message, host);
} else {
throw new ExecuteException("fail after try all nodes");
}
@ -132,33 +129,33 @@ public class NettyExecutorManager extends AbstractExecutorManager<Boolean> {
@Override
public void executeDirectly(ExecutionContext context) throws ExecuteException {
Host host = context.getHost();
doExecute(host, context.getCommand());
doExecute(host, context.getMessage());
}
/**
* execute logic
*
* @param host host
* @param command command
* @param message command
* @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
int retryCount = 3;
boolean success = false;
do {
try {
nettyRemotingClient.send(host, command);
nettyRemotingClient.send(host, message);
success = true;
} catch (Exception ex) {
log.error("Send command to {} error, command: {}", host, command, ex);
log.error("Send command to {} error, command: {}", host, message, ex);
retryCount--;
ThreadUtils.sleep(Constants.SLEEP_TIME_MILLIS);
}
} while (retryCount >= 0 && !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.repository.TaskInstanceDao;
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.config.MasterConfig;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable;
import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThreadPool;
import org.apache.dolphinscheduler.service.process.ProcessService;
import java.util.Optional;
@ -43,15 +43,15 @@ public class TaskDelayEventHandler implements TaskEventHandler {
@Autowired
private ProcessInstanceExecCacheManager processInstanceExecCacheManager;
@Autowired
private ProcessService processService;
@Autowired
private TaskInstanceDao taskInstanceDao;
@Autowired
private WorkflowExecuteThreadPool workflowExecuteThreadPool;
@Autowired
private MasterConfig masterConfig;
@Override
public void handleTaskEvent(TaskEvent taskEvent) throws TaskEventHandleError {
int taskInstanceId = taskEvent.getTaskInstanceId();
@ -111,9 +111,13 @@ public class TaskDelayEventHandler implements TaskEventHandler {
private void sendAckToWorker(TaskEvent taskEvent) {
// If event handle success, send ack to worker to otherwise the worker will retry this event
TaskExecuteRunningAckMessage taskExecuteRunningAckMessage =
new TaskExecuteRunningAckMessage(true, taskEvent.getTaskInstanceId());
taskEvent.getChannel().writeAndFlush(taskExecuteRunningAckMessage.convert2Command());
TaskExecuteRunningMessageAck taskExecuteRunningMessageAck =
new TaskExecuteRunningMessageAck(true,
taskEvent.getTaskInstanceId(),
masterConfig.getMasterAddress(),
taskEvent.getWorkerAddress(),
System.currentTimeMillis());
taskEvent.getChannel().writeAndFlush(taskExecuteRunningMessageAck.convert2Command());
}
@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.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.config.MasterConfig;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
@ -69,12 +69,12 @@ public class TaskRejectByWorkerEventHandler implements TaskEventHandler {
}
public void sendAckToWorker(TaskEvent taskEvent) {
TaskRejectAckCommand taskRejectAckMessage = new TaskRejectAckCommand(true,
TaskRejectMessageAck taskRejectMessageAck = new TaskRejectMessageAck(true,
taskEvent.getTaskInstanceId(),
masterConfig.getMasterAddress(),
taskEvent.getWorkerAddress(),
System.currentTimeMillis());
taskEvent.getChannel().writeAndFlush(taskRejectAckMessage.convert2Command());
taskEvent.getChannel().writeAndFlush(taskRejectMessageAck.convert2Command());
}
@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.repository.TaskInstanceDao;
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.config.MasterConfig;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
@ -120,7 +120,7 @@ public class TaskResultEventHandler implements TaskEventHandler {
return;
}
// 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(),
masterConfig.getMasterAddress(),
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.repository.TaskInstanceDao;
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.config.MasterConfig;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable;
import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThreadPool;
@ -45,6 +46,9 @@ public class TaskRunningEventHandler implements TaskEventHandler {
@Autowired
private TaskInstanceDao taskInstanceDao;
@Autowired
private MasterConfig masterConfig;
@Override
public void handleTaskEvent(TaskEvent taskEvent) throws TaskEventHandleError {
int taskInstanceId = taskEvent.getTaskInstanceId();
@ -103,9 +107,14 @@ public class TaskRunningEventHandler implements TaskEventHandler {
private void sendAckToWorker(TaskEvent taskEvent) {
// If event handle success, send ack to worker to otherwise the worker will retry this event
TaskExecuteRunningAckMessage taskExecuteRunningAckMessage =
new TaskExecuteRunningAckMessage(true, taskEvent.getTaskInstanceId());
taskEvent.getChannel().writeAndFlush(taskExecuteRunningAckMessage.convert2Command());
TaskExecuteRunningMessageAck taskExecuteRunningMessageAck =
new TaskExecuteRunningMessageAck(
true,
taskEvent.getTaskInstanceId(),
masterConfig.getMasterAddress(),
taskEvent.getWorkerAddress(),
System.currentTimeMillis());
taskEvent.getChannel().writeAndFlush(taskExecuteRunningMessageAck.convert2Command());
}
@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.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
import org.apache.dolphinscheduler.server.master.metrics.TaskMetrics;
import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable;
import org.apache.dolphinscheduler.server.master.runner.task.ITaskProcessor;
@ -76,7 +77,11 @@ public class TaskStateEventHandler implements StateEventHandler {
workflowExecuteRunnable.taskFinished(task);
if (task.getTaskGroupId() > 0) {
log.info("The task instance need to release task Group: {}", task.getTaskGroupId());
try {
workflowExecuteRunnable.releaseTaskGroup(task);
} catch (RemotingException | InterruptedException e) {
throw new StateEventHandleException("Release task group failed", e);
}
}
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.repository.TaskInstanceDao;
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.processor.queue.TaskEvent;
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.utils.JSONUtils;
import org.apache.dolphinscheduler.remote.command.CacheExpireCommand;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.cache.CacheExpireRequest;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import lombok.extern.slf4j.Slf4j;
@ -31,7 +31,6 @@ import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel;
/**
@ -45,28 +44,30 @@ public class CacheProcessor implements NettyRequestProcessor {
private CacheManager cacheManager;
@Override
public void process(Channel channel, Command command) {
Preconditions.checkArgument(CommandType.CACHE_EXPIRE == command.getType(),
String.format("invalid command type: %s", command.getType()));
public void process(Channel channel, Message message) {
CacheExpireRequest cacheExpireRequest = JSONUtils.parseObject(message.getBody(), CacheExpireRequest.class);
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;
}
CacheType cacheType = cacheExpireCommand.getCacheType();
CacheType cacheType = cacheExpireRequest.getCacheType();
Cache cache = cacheManager.getCache(cacheType.getCacheName());
if (cache != null) {
cache.evict(cacheExpireCommand.getCacheKey());
log.info("cache evict, type:{}, key:{}", cacheType.getCacheName(), cacheExpireCommand.getCacheKey());
cache.evict(cacheExpireRequest.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.utils.JSONUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.command.WorkflowStateEventChangeCommand;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.workflow.WorkflowStateEventChangeRequest;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.event.StateEvent;
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.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel;
/**
@ -49,17 +48,14 @@ public class StateEventProcessor implements NettyRequestProcessor {
private StateEventResponseService stateEventResponseService;
@Override
public void process(Channel channel, Command command) {
Preconditions.checkArgument(CommandType.STATE_EVENT_REQUEST == command.getType(),
String.format("invalid command type: %s", command.getType()));
WorkflowStateEventChangeCommand workflowStateEventChangeCommand =
JSONUtils.parseObject(command.getBody(), WorkflowStateEventChangeCommand.class);
public void process(Channel channel, Message message) {
WorkflowStateEventChangeRequest workflowStateEventChangeRequest =
JSONUtils.parseObject(message.getBody(), WorkflowStateEventChangeRequest.class);
StateEvent stateEvent;
if (workflowStateEventChangeCommand.getDestTaskInstanceId() == 0) {
stateEvent = createWorkflowStateEvent(workflowStateEventChangeCommand);
if (workflowStateEventChangeRequest.getDestTaskInstanceId() == 0) {
stateEvent = createWorkflowStateEvent(workflowStateEventChangeRequest);
} else {
stateEvent = createTaskStateEvent(workflowStateEventChangeCommand);
stateEvent = createTaskStateEvent(workflowStateEventChangeRequest);
}
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()
.processInstanceId(workflowStateEventChangeCommand.getDestProcessInstanceId())
.taskInstanceId(workflowStateEventChangeCommand.getDestTaskInstanceId())
.processInstanceId(workflowStateEventChangeRequest.getDestProcessInstanceId())
.taskInstanceId(workflowStateEventChangeRequest.getDestTaskInstanceId())
.type(StateEventType.TASK_STATE_CHANGE)
.key(workflowStateEventChangeCommand.getKey())
.key(workflowStateEventChangeRequest.getKey())
.build();
}
private WorkflowStateEvent createWorkflowStateEvent(WorkflowStateEventChangeCommand workflowStateEventChangeCommand) {
WorkflowExecutionStatus workflowExecutionStatus = workflowStateEventChangeCommand.getSourceStatus();
if (workflowStateEventChangeCommand.getSourceProcessInstanceId() != workflowStateEventChangeCommand
private WorkflowStateEvent createWorkflowStateEvent(WorkflowStateEventChangeRequest workflowStateEventChangeRequest) {
WorkflowExecutionStatus workflowExecutionStatus = workflowStateEventChangeRequest.getSourceStatus();
if (workflowStateEventChangeRequest.getSourceProcessInstanceId() != workflowStateEventChangeRequest
.getDestProcessInstanceId()) {
workflowExecutionStatus = WorkflowExecutionStatus.RUNNING_EXECUTION;
}
return WorkflowStateEvent.builder()
.processInstanceId(workflowStateEventChangeCommand.getDestProcessInstanceId())
.processInstanceId(workflowStateEventChangeRequest.getDestProcessInstanceId())
.type(StateEventType.PROCESS_STATE_CHANGE)
.status(workflowExecutionStatus)
.key(workflowStateEventChangeCommand.getKey())
.key(workflowStateEventChangeRequest.getKey())
.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.plugin.task.api.utils.LogUtils;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.command.TaskExecuteResultCommand;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.task.TaskExecuteResultMessage;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
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.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel;
/**
@ -39,7 +38,7 @@ import io.netty.channel.Channel;
*/
@Component
@Slf4j
public class TaskExecuteResponseProcessor implements NettyRequestProcessor {
public class TaskExecuteResultProcessor implements NettyRequestProcessor {
@Autowired
private TaskEventService taskEventService;
@ -49,15 +48,12 @@ public class TaskExecuteResponseProcessor implements NettyRequestProcessor {
* need master process , state persistence
*
* @param channel channel
* @param command command
* @param message command
*/
@Override
public void process(Channel channel, Command command) {
Preconditions.checkArgument(CommandType.TASK_EXECUTE_RESULT == command.getType(),
String.format("invalid command type : %s", command.getType()));
TaskExecuteResultCommand taskExecuteResultMessage = JSONUtils.parseObject(command.getBody(),
TaskExecuteResultCommand.class);
public void process(Channel channel, Message message) {
TaskExecuteResultMessage taskExecuteResultMessage = JSONUtils.parseObject(message.getBody(),
TaskExecuteResultMessage.class);
TaskEvent taskResultEvent = TaskEvent.newResultEvent(taskExecuteResultMessage,
channel,
taskExecuteResultMessage.getMessageSenderAddress());
@ -69,4 +65,9 @@ public class TaskExecuteResponseProcessor implements NettyRequestProcessor {
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;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.command.TaskExecuteRunningCommand;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.task.TaskExecuteRunningMessage;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
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.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel;
/**
@ -47,14 +46,12 @@ public class TaskExecuteRunningProcessor implements NettyRequestProcessor {
* task ack process
*
* @param channel channel channel
* @param command command TaskExecuteAckCommand
* @param message command TaskExecuteAckCommand
*/
@Override
public void process(Channel channel, Command command) {
Preconditions.checkArgument(CommandType.TASK_EXECUTE_RUNNING == command.getType(),
String.format("invalid command type : %s", command.getType()));
TaskExecuteRunningCommand taskExecuteRunningMessage =
JSONUtils.parseObject(command.getBody(), TaskExecuteRunningCommand.class);
public void process(Channel channel, Message message) {
TaskExecuteRunningMessage taskExecuteRunningMessage =
JSONUtils.parseObject(message.getBody(), TaskExecuteRunningMessage.class);
log.info("taskExecuteRunningCommand: {}", taskExecuteRunningMessage);
TaskEvent taskEvent = TaskEvent.newRunningEvent(taskExecuteRunningMessage,
@ -63,4 +60,9 @@ public class TaskExecuteRunningProcessor implements NettyRequestProcessor {
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.dao.entity.TaskDefinition;
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionDao;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.command.TaskExecuteStartCommand;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.task.TaskExecuteStartMessage;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.runner.StreamTaskExecuteRunnable;
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.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel;
/**
@ -49,28 +48,31 @@ public class TaskExecuteStartProcessor implements NettyRequestProcessor {
private TaskDefinitionDao taskDefinitionDao;
@Override
public void process(Channel channel, Command command) {
Preconditions.checkArgument(CommandType.TASK_EXECUTE_START == command.getType(),
String.format("invalid command type : %s", command.getType()));
TaskExecuteStartCommand taskExecuteStartCommand =
JSONUtils.parseObject(command.getBody(), TaskExecuteStartCommand.class);
log.info("taskExecuteStartCommand: {}", taskExecuteStartCommand);
public void process(Channel channel, Message message) {
TaskExecuteStartMessage taskExecuteStartMessage =
JSONUtils.parseObject(message.getBody(), TaskExecuteStartMessage.class);
log.info("taskExecuteStartCommand: {}", taskExecuteStartMessage);
TaskDefinition taskDefinition = taskDefinitionDao.findTaskDefinition(
taskExecuteStartCommand.getTaskDefinitionCode(), taskExecuteStartCommand.getTaskDefinitionVersion());
taskExecuteStartMessage.getTaskDefinitionCode(), taskExecuteStartMessage.getTaskDefinitionVersion());
if (taskDefinition == null) {
log.error("Task definition can not be found, taskDefinitionCode:{}, taskDefinitionVersion:{}",
taskExecuteStartCommand.getTaskDefinitionCode(),
taskExecuteStartCommand.getTaskDefinitionVersion());
taskExecuteStartMessage.getTaskDefinitionCode(),
taskExecuteStartMessage.getTaskDefinitionVersion());
return;
}
streamTaskExecuteThreadPool.execute(new StreamTaskExecuteRunnable(taskDefinition, taskExecuteStartCommand));
streamTaskExecuteThreadPool.execute(new StreamTaskExecuteRunnable(taskDefinition, taskExecuteStartMessage));
// response
Command response = new Command(command.getOpaque());
response.setType(CommandType.TASK_EXECUTE_START);
Message response = new Message(message.getOpaque());
response.setType(MessageType.TASK_EXECUTE_START);
response.setBody(new byte[0]);
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;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.command.TaskKillResponseCommand;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.task.TaskKillResponse;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel;
/**
@ -42,17 +41,18 @@ public class TaskKillResponseProcessor implements NettyRequestProcessor {
* need master process , state persistence
*
* @param channel channel
* @param command command
* @param message command
*/
@Override
public void process(Channel channel, Command command) {
Preconditions.checkArgument(CommandType.TASK_KILL_RESPONSE == command.getType(),
String.format("invalid command type : %s", command.getType()));
TaskKillResponseCommand responseCommand =
JSONUtils.parseObject(command.getBody(), TaskKillResponseCommand.class);
public void process(Channel channel, Message message) {
TaskKillResponse responseCommand = JSONUtils.parseObject(message.getBody(), TaskKillResponse.class);
log.info("[TaskInstance-{}] Received task kill response command : {}",
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.plugin.task.api.utils.LogUtils;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.command.TaskRejectCommand;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.task.TaskRejectMessage;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
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.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel;
/**
@ -48,13 +47,11 @@ public class TaskRecallProcessor implements NettyRequestProcessor {
* task ack process
*
* @param channel channel channel
* @param command command TaskExecuteAckCommand
* @param message command TaskExecuteAckCommand
*/
@Override
public void process(Channel channel, Command command) {
Preconditions.checkArgument(CommandType.TASK_REJECT == command.getType(),
String.format("invalid command type : %s", command.getType()));
TaskRejectCommand recallCommand = JSONUtils.parseObject(command.getBody(), TaskRejectCommand.class);
public void process(Channel channel, Message message) {
TaskRejectMessage recallCommand = JSONUtils.parseObject(message.getBody(), TaskRejectMessage.class);
TaskEvent taskEvent = TaskEvent.newRecallEvent(recallCommand, channel);
try (
final LogUtils.MDCAutoClosableContext mdcAutoClosableContext = LogUtils.setWorkflowAndTaskInstanceIDMDC(
@ -63,4 +60,9 @@ public class TaskRecallProcessor implements NettyRequestProcessor {
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;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.command.TaskUpdatePidCommand;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.task.TaskUpdatePidMessage;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
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.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel;
/**
@ -47,20 +46,23 @@ public class TaskUpdatePidProcessor implements NettyRequestProcessor {
* task ack process
*
* @param channel channel channel
* @param command command TaskExecuteAckCommand
* @param message command TaskExecuteAckCommand
*/
@Override
public void process(Channel channel, Command command) {
Preconditions.checkArgument(CommandType.TASK_UPDATE_PID == command.getType(),
String.format("invalid command type : %s", command.getType()));
TaskUpdatePidCommand taskUpdatePidCommand =
JSONUtils.parseObject(command.getBody(), TaskUpdatePidCommand.class);
log.info("taskUpdatePidCommand: {}", taskUpdatePidCommand);
public void process(Channel channel, Message message) {
TaskUpdatePidMessage taskUpdatePidRequest =
JSONUtils.parseObject(message.getBody(), TaskUpdatePidMessage.class);
log.info("taskUpdatePidCommand: {}", taskUpdatePidRequest);
TaskEvent taskEvent = TaskEvent.newUpdatePidEvent(taskUpdatePidCommand,
TaskEvent taskEvent = TaskEvent.newUpdatePidEvent(taskUpdatePidRequest,
channel,
taskUpdatePidCommand.getMessageSenderAddress());
taskUpdatePidRequest.getMessageSenderAddress());
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.utils.JSONUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.command.TaskEventChangeCommand;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.task.TaskWakeupRequest;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.event.TaskStateEvent;
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.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel;
/**
@ -40,19 +39,15 @@ import io.netty.channel.Channel;
*/
@Component
@Slf4j
public class TaskEventProcessor implements NettyRequestProcessor {
public class TaskWakeupProcessor implements NettyRequestProcessor {
@Autowired
private StateEventResponseService stateEventResponseService;
@Override
public void process(Channel channel, Command command) {
Preconditions.checkArgument(CommandType.TASK_FORCE_STATE_EVENT_REQUEST == command.getType()
|| CommandType.TASK_WAKEUP_EVENT_REQUEST == command.getType(),
String.format("invalid command type: %s", command.getType()));
TaskEventChangeCommand taskEventChangeCommand =
JSONUtils.parseObject(command.getBody(), TaskEventChangeCommand.class);
public void process(Channel channel, Message message) {
TaskWakeupRequest taskEventChangeCommand =
JSONUtils.parseObject(message.getBody(), TaskWakeupRequest.class);
TaskStateEvent stateEvent = TaskStateEvent.builder()
.processInstanceId(taskEventChangeCommand.getProcessInstanceId())
.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;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.command.WorkflowExecutingDataRequestCommand;
import org.apache.dolphinscheduler.remote.command.WorkflowExecutingDataResponseCommand;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.workflow.WorkflowExecutingDataRequest;
import org.apache.dolphinscheduler.remote.command.workflow.WorkflowExecutingDataResponse;
import org.apache.dolphinscheduler.remote.dto.WorkflowExecuteDto;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
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.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel;
/**
@ -47,20 +46,22 @@ public class WorkflowExecutingDataRequestProcessor implements NettyRequestProces
private ExecutingService executingService;
@Override
public void process(Channel channel, Command command) {
Preconditions.checkArgument(CommandType.WORKFLOW_EXECUTING_DATA_REQUEST == command.getType(),
String.format("invalid command type: %s", command.getType()));
WorkflowExecutingDataRequestCommand requestCommand =
JSONUtils.parseObject(command.getBody(), WorkflowExecutingDataRequestCommand.class);
public void process(Channel channel, Message message) {
WorkflowExecutingDataRequest requestCommand =
JSONUtils.parseObject(message.getBody(), WorkflowExecutingDataRequest.class);
log.info("received command, processInstanceId:{}", requestCommand.getProcessInstanceId());
Optional<WorkflowExecuteDto> workflowExecuteDtoOptional =
executingService.queryWorkflowExecutingData(requestCommand.getProcessInstanceId());
WorkflowExecutingDataResponseCommand responseCommand = new WorkflowExecutingDataResponseCommand();
WorkflowExecutingDataResponse responseCommand = new WorkflowExecutingDataResponse();
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;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.command.WorkflowMetricsCleanUpCommand;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.workflow.WorkflowMetricsCleanUpRequest;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.metrics.ProcessInstanceMetrics;
import org.springframework.stereotype.Component;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel;
@Component
public class WorkflowMetricsCleanUpProcessor implements NettyRequestProcessor {
@Override
public void process(Channel channel, Command command) {
Preconditions.checkArgument(CommandType.WORKFLOW_METRICS_CLEANUP == command.getType(),
String.format("invalid command type: %s", command.getType()));
WorkflowMetricsCleanUpCommand workflowMetricsCleanUpCommand =
JSONUtils.parseObject(command.getBody(), WorkflowMetricsCleanUpCommand.class);
public void process(Channel channel, Message message) {
WorkflowMetricsCleanUpRequest workflowMetricsCleanUpRequest =
JSONUtils.parseObject(message.getBody(), WorkflowMetricsCleanUpRequest.class);
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.thread.BaseDaemonThread;
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.event.StateEvent;
import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable;
@ -133,7 +133,7 @@ public class StateEventResponseService {
private void writeResponse(StateEvent stateEvent) {
Channel channel = stateEvent.getChannel();
if (channel != null) {
StateEventResponseCommand command = new StateEventResponseCommand(stateEvent.getKey());
StateEventResponse command = new StateEventResponse(stateEvent.getKey());
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.utils.DateUtils;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.remote.command.TaskExecuteResultCommand;
import org.apache.dolphinscheduler.remote.command.TaskExecuteRunningCommand;
import org.apache.dolphinscheduler.remote.command.TaskRejectCommand;
import org.apache.dolphinscheduler.remote.command.TaskUpdatePidCommand;
import org.apache.dolphinscheduler.remote.command.task.TaskExecuteResultMessage;
import org.apache.dolphinscheduler.remote.command.task.TaskExecuteRunningMessage;
import org.apache.dolphinscheduler.remote.command.task.TaskRejectMessage;
import org.apache.dolphinscheduler.remote.command.task.TaskUpdatePidMessage;
import java.util.Date;
@ -112,7 +112,7 @@ public class TaskEvent {
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();
event.setProcessInstanceId(command.getProcessInstanceId());
event.setTaskInstanceId(command.getTaskInstanceId());
@ -127,7 +127,7 @@ public class TaskEvent {
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();
event.setProcessInstanceId(command.getProcessInstanceId());
event.setTaskInstanceId(command.getTaskInstanceId());
@ -145,7 +145,7 @@ public class TaskEvent {
return event;
}
public static TaskEvent newRecallEvent(TaskRejectCommand command, Channel channel) {
public static TaskEvent newRecallEvent(TaskRejectMessage command, Channel channel) {
TaskEvent event = new TaskEvent();
event.setTaskInstanceId(command.getTaskInstanceId());
event.setProcessInstanceId(command.getProcessInstanceId());
@ -163,7 +163,7 @@ public class TaskEvent {
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();
event.setProcessInstanceId(command.getProcessInstanceId());
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;
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.processor.LoggerRequestProcessor;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
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 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 java.util.List;
import lombok.extern.slf4j.Slf4j;
@ -52,40 +42,7 @@ public class MasterRPCServer implements AutoCloseable {
private MasterConfig masterConfig;
@Autowired
private TaskExecuteRunningProcessor taskExecuteRunningProcessor;
@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;
private List<NettyRequestProcessor> nettyRequestProcessors;
public void start() {
log.info("Starting Master RPC Server...");
@ -93,27 +50,10 @@ public class MasterRPCServer implements AutoCloseable {
NettyServerConfig serverConfig = new NettyServerConfig();
serverConfig.setListenPort(masterConfig.getListenPort());
this.nettyRemotingServer = new NettyRemotingServer(serverConfig);
this.nettyRemotingServer.registerProcessor(CommandType.TASK_EXECUTE_RUNNING, taskExecuteRunningProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.TASK_UPDATE_PID, updatePidProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.TASK_EXECUTE_RESULT, taskExecuteResponseProcessor);
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);
for (NettyRequestProcessor nettyRequestProcessor : nettyRequestProcessors) {
this.nettyRemotingServer.registerProcessor(nettyRequestProcessor);
log.info("Success register netty processor: {}", nettyRequestProcessor.getClass().getName());
}
this.nettyRemotingServer.start();
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;
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.exceptions.RemotingException;
import org.apache.dolphinscheduler.remote.utils.Host;
@ -41,9 +41,9 @@ public class MasterRpcClient {
log.info("Success initialized ApiServerRPCClient...");
}
public Command sendSyncCommand(@NonNull Host host,
@NonNull Command rpcCommand) throws RemotingException, InterruptedException {
return client.sendSync(host, rpcCommand, DEFAULT_TIME_OUT_MILLS);
public Message sendSyncCommand(@NonNull Host host,
@NonNull Message rpcMessage) throws RemotingException, InterruptedException {
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.parser.ParamUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
import org.apache.dolphinscheduler.remote.command.TaskDispatchCommand;
import org.apache.dolphinscheduler.remote.command.TaskExecuteRunningAckMessage;
import org.apache.dolphinscheduler.remote.command.TaskExecuteStartCommand;
import org.apache.dolphinscheduler.remote.command.task.TaskDispatchMessage;
import org.apache.dolphinscheduler.remote.command.task.TaskExecuteRunningMessageAck;
import org.apache.dolphinscheduler.remote.command.task.TaskExecuteStartMessage;
import org.apache.dolphinscheduler.server.master.builder.TaskExecutionContextBuilder;
import org.apache.dolphinscheduler.server.master.cache.StreamTaskInstanceExecCacheManager;
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
@ -103,7 +103,7 @@ public class StreamTaskExecuteRunnable implements Runnable {
protected ProcessDefinition processDefinition;
protected TaskExecuteStartCommand taskExecuteStartCommand;
protected TaskExecuteStartMessage taskExecuteStartMessage;
/**
* task event queue
@ -112,7 +112,7 @@ public class StreamTaskExecuteRunnable implements Runnable {
private TaskRunnableStatus taskRunnableStatus = TaskRunnableStatus.CREATED;
public StreamTaskExecuteRunnable(TaskDefinition taskDefinition, TaskExecuteStartCommand taskExecuteStartCommand) {
public StreamTaskExecuteRunnable(TaskDefinition taskDefinition, TaskExecuteStartMessage taskExecuteStartMessage) {
this.processService = SpringApplicationContext.getBean(ProcessService.class);
this.masterConfig = SpringApplicationContext.getBean(MasterConfig.class);
this.dispatcher = SpringApplicationContext.getBean(ExecutorDispatcher.class);
@ -122,7 +122,7 @@ public class StreamTaskExecuteRunnable implements Runnable {
this.streamTaskInstanceExecCacheManager =
SpringApplicationContext.getBean(StreamTaskInstanceExecCacheManager.class);
this.taskDefinition = taskDefinition;
this.taskExecuteStartCommand = taskExecuteStartCommand;
this.taskExecuteStartMessage = taskExecuteStartMessage;
}
public TaskInstance getTaskInstance() {
@ -153,7 +153,7 @@ public class StreamTaskExecuteRunnable implements Runnable {
return;
}
TaskDispatchCommand dispatchCommand = new TaskDispatchCommand(taskExecutionContext,
TaskDispatchMessage dispatchCommand = new TaskDispatchMessage(taskExecutionContext,
masterConfig.getMasterAddress(),
taskExecutionContext.getHost(),
System.currentTimeMillis());
@ -296,7 +296,7 @@ public class StreamTaskExecuteRunnable implements Runnable {
taskInstance.setDelayTime(taskDefinition.getDelayTime());
// task dry run flag
taskInstance.setDryRun(taskExecuteStartCommand.getDryRun());
taskInstance.setDryRun(taskExecuteStartMessage.getDryRun());
taskInstance.setWorkerGroup(StringUtils.isBlank(taskDefinition.getWorkerGroup()) ? DEFAULT_WORKER_GROUP
: taskDefinition.getWorkerGroup());
@ -318,8 +318,8 @@ public class StreamTaskExecuteRunnable implements Runnable {
}
taskInstance.setTaskExecuteType(taskDefinition.getTaskExecuteType());
taskInstance.setExecutorId(taskExecuteStartCommand.getExecutorId());
taskInstance.setExecutorName(taskExecuteStartCommand.getExecutorName());
taskInstance.setExecutorId(taskExecuteStartMessage.getExecutorId());
taskInstance.setExecutorName(taskExecuteStartMessage.getExecutorName());
return taskInstance;
}
@ -461,7 +461,7 @@ public class StreamTaskExecuteRunnable implements Runnable {
public Map<String, Property> paramParsingPreparation(@NonNull TaskInstance taskInstance,
@NonNull AbstractParameters parameters) {
// assign value to definedParams here
Map<String, String> globalParamsMap = taskExecuteStartCommand.getStartParams();
Map<String, String> globalParamsMap = taskExecuteStartMessage.getStartParams();
Map<String, Property> globalParams = ParamUtils.getUserDefParamsMap(globalParamsMap);
// combining local and global parameters
@ -487,9 +487,14 @@ public class StreamTaskExecuteRunnable implements Runnable {
private void sendAckToWorker(TaskEvent taskEvent) {
// If event handle success, send ack to worker to otherwise the worker will retry this event
TaskExecuteRunningAckMessage taskExecuteRunningAckMessage =
new TaskExecuteRunningAckMessage(true, taskEvent.getTaskInstanceId());
taskEvent.getChannel().writeAndFlush(taskExecuteRunningAckMessage.convert2Command());
TaskExecuteRunningMessageAck taskExecuteRunningMessageAck =
new TaskExecuteRunningMessageAck(
true,
taskEvent.getTaskInstanceId(),
masterConfig.getMasterAddress(),
taskEvent.getWorkerAddress(),
System.currentTimeMillis());
taskEvent.getChannel().writeAndFlush(taskExecuteRunningMessageAck.convert2Command());
}
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.model.Property;
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.WorkflowHostChangeResponse;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
@ -476,7 +478,7 @@ public class WorkflowExecuteRunnable implements Callable<WorkflowSubmitStatue> {
* release task group
*
*/
public void releaseTaskGroup(TaskInstance taskInstance) {
public void releaseTaskGroup(TaskInstance taskInstance) throws RemotingException, InterruptedException {
if (taskInstance.getTaskGroupId() > 0) {
TaskInstance nextTaskInstance = this.processService.releaseTaskGroup(taskInstance);
if (nextTaskInstance != null) {
@ -490,8 +492,8 @@ public class WorkflowExecuteRunnable implements Callable<WorkflowSubmitStatue> {
} else {
ProcessInstance processInstance =
this.processService.findProcessInstanceById(nextTaskInstance.getProcessInstanceId());
this.processService.sendStartTask2Master(processInstance, nextTaskInstance.getId(),
org.apache.dolphinscheduler.remote.command.CommandType.TASK_WAKEUP_EVENT_REQUEST);
this.masterRpcClient.sendSyncCommand(Host.of(processInstance.getHost()),
new TaskWakeupRequest(processInstance.getId(), nextTaskInstance.getId()).convert2Command());
}
}
}
@ -1420,17 +1422,17 @@ public class WorkflowExecuteRunnable implements Callable<WorkflowSubmitStatue> {
return false;
}
try {
org.apache.dolphinscheduler.remote.command.Command command =
Message message =
masterRpcClient.sendSyncCommand(Host.of(taskInstance.getHost()),
new WorkflowHostChangeRequest(taskInstance.getId(), masterAddress).convert2Command());
if (command == null) {
if (message == null) {
log.error(
"Takeover task instance failed, the worker {} might not be alive, will try to create a new task instance",
taskInstance.getHost());
return false;
}
WorkflowHostChangeResponse workflowHostChangeResponse =
JSONUtils.parseObject(command.getBody(), WorkflowHostChangeResponse.class);
JSONUtils.parseObject(message.getBody(), WorkflowHostChangeResponse.class);
if (workflowHostChangeResponse == null || !workflowHostChangeResponse.isSuccess()) {
log.error(
"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.plugin.task.api.enums.TaskExecutionStatus;
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.utils.Host;
import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager;
@ -203,10 +203,10 @@ public class WorkflowExecuteThreadPool extends ThreadPoolTaskExecutor {
taskInstance.getName(), taskInstance.getId());
return;
}
WorkflowStateEventChangeCommand workflowStateEventChangeCommand = new WorkflowStateEventChangeCommand(
WorkflowStateEventChangeRequest workflowStateEventChangeRequest = new WorkflowStateEventChangeRequest(
finishProcessInstance.getId(), 0, finishProcessInstance.getState(), processInstance.getId(),
taskInstance.getId());
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.TaskExecutionContext;
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.server.master.dispatch.context.ExecutionContext;
import org.apache.dolphinscheduler.server.master.dispatch.enums.ExecutorType;
@ -173,7 +173,7 @@ public class CommonTaskProcessor extends BaseTaskProcessor {
}
private void killRemoteTask() throws ExecuteException {
TaskKillRequestCommand killCommand = new TaskKillRequestCommand();
TaskKillRequest killCommand = new TaskKillRequest();
killCommand.setTaskInstanceId(taskInstance.getId());
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.model.Property;
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.utils.Host;
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
@ -224,11 +224,11 @@ public class SubTaskProcessor extends BaseTaskProcessor {
}
private void sendToSubProcess() {
WorkflowStateEventChangeCommand workflowStateEventChangeCommand = new WorkflowStateEventChangeCommand(
WorkflowStateEventChangeRequest workflowStateEventChangeRequest = new WorkflowStateEventChangeRequest(
processInstance.getId(), taskInstance.getId(), subProcessInstance.getState(),
subProcessInstance.getId(), 0);
Host host = new Host(subProcessInstance.getHost());
this.stateEventCallbackService.sendResult(host, workflowStateEventChangeCommand.convert2Command());
this.stateEventCallbackService.sendResult(host, workflowStateEventChangeRequest.convert2Command());
}
@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
*/
@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;

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.TaskInstance;
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.TaskDispatchCommand;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.task.TaskDispatchMessage;
import org.apache.dolphinscheduler.remote.utils.Host;
import org.apache.dolphinscheduler.server.master.builder.TaskExecutionContextBuilder;
import org.apache.dolphinscheduler.server.master.dispatch.context.ExecutionContext;
@ -52,13 +52,13 @@ public class ExecutionContextTestUtils {
.buildProcessDefinitionRelatedInfo(processDefinition)
.create();
TaskDispatchCommand requestCommand = new TaskDispatchCommand(context,
TaskDispatchMessage requestCommand = new TaskDispatchMessage(context,
"127.0.0.1:5678",
"127.0.0.1:5678",
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)));
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;
import org.apache.dolphinscheduler.remote.NettyRemotingServer;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.config.NettyServerConfig;
import org.apache.dolphinscheduler.server.master.dispatch.context.ExecutionContext;
import org.apache.dolphinscheduler.server.master.dispatch.exceptions.ExecuteException;
@ -64,8 +63,7 @@ public class ExecutorDispatcherTest {
final NettyServerConfig serverConfig = new NettyServerConfig();
serverConfig.setListenPort(port);
NettyRemotingServer nettyRemotingServer = new NettyRemotingServer(serverConfig);
nettyRemotingServer.registerProcessor(CommandType.TASK_DISPATCH_REQUEST, Mockito.mock(
TaskDispatchProcessor.class));
nettyRemotingServer.registerProcessor(Mockito.mock(TaskDispatchProcessor.class));
nettyRemotingServer.start();
//
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.plugin.task.api.TaskExecutionContext;
import org.apache.dolphinscheduler.remote.NettyRemotingServer;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.TaskDispatchCommand;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.task.TaskDispatchMessage;
import org.apache.dolphinscheduler.remote.config.NettyServerConfig;
import org.apache.dolphinscheduler.remote.utils.Host;
import org.apache.dolphinscheduler.server.master.builder.TaskExecutionContextBuilder;
@ -56,9 +56,7 @@ public class NettyExecutorManagerTest {
final NettyServerConfig serverConfig = new NettyServerConfig();
serverConfig.setListenPort(30000);
NettyRemotingServer nettyRemotingServer = new NettyRemotingServer(serverConfig);
nettyRemotingServer.registerProcessor(
org.apache.dolphinscheduler.remote.command.CommandType.TASK_DISPATCH_REQUEST,
new TaskDispatchProcessor());
nettyRemotingServer.registerProcessor(new TaskDispatchProcessor());
nettyRemotingServer.start();
TaskInstance taskInstance = Mockito.mock(TaskInstance.class);
ProcessDefinition processDefinition = Mockito.mock(ProcessDefinition.class);
@ -95,8 +93,8 @@ public class NettyExecutorManagerTest {
});
}
private Command toCommand(TaskExecutionContext taskExecutionContext) {
TaskDispatchCommand requestCommand = new TaskDispatchCommand(taskExecutionContext,
private Message toCommand(TaskExecutionContext taskExecutionContext) {
TaskDispatchMessage requestCommand = new TaskDispatchMessage(taskExecutionContext,
"127.0.0.1:5678",
"127.0.0.1:1234",
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.dao.entity.Tenant;
import org.apache.dolphinscheduler.remote.command.CacheExpireCommand;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.cache.CacheExpireRequest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -61,9 +61,9 @@ public class CacheProcessorTest {
public void testProcess() {
Tenant tenant = new Tenant();
tenant.setId(1);
CacheExpireCommand cacheExpireCommand = new CacheExpireCommand(CacheType.TENANT, "1");
Command command = cacheExpireCommand.convert2Command();
CacheExpireRequest cacheExpireRequest = new CacheExpireRequest(CacheType.TENANT, "1");
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;
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.TaskEventService;
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
@ -43,7 +43,7 @@ public class TaskAckProcessorTest {
private TaskExecuteRunningProcessor taskExecuteRunningProcessor;
private TaskEventService taskEventService;
private ProcessService processService;
private TaskExecuteRunningCommand taskExecuteRunningMessage;
private TaskExecuteRunningMessage taskExecuteRunningMessage;
private TaskEvent taskResponseEvent;
private Channel channel;
@ -66,7 +66,7 @@ public class TaskAckProcessorTest {
channel = Mockito.mock(Channel.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",
System.currentTimeMillis());
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;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.command.TaskKillResponseCommand;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.task.TaskKillResponse;
import java.util.ArrayList;
@ -38,7 +38,7 @@ public class TaskKillResponseProcessorTest {
private TaskKillResponseProcessor taskKillResponseProcessor;
private TaskKillResponseCommand taskKillResponseCommand;
private TaskKillResponse taskKillResponse;
private Channel channel;
@ -46,25 +46,25 @@ public class TaskKillResponseProcessorTest {
public void before() {
taskKillResponseProcessor = new TaskKillResponseProcessor();
channel = Mockito.mock(Channel.class);
taskKillResponseCommand = new TaskKillResponseCommand();
taskKillResponseCommand.setAppIds(
taskKillResponse = new TaskKillResponse();
taskKillResponse.setAppIds(
new ArrayList<String>() {
{
add("task_1");
}
});
taskKillResponseCommand.setHost("localhost");
taskKillResponseCommand.setProcessId(1);
taskKillResponseCommand.setStatus(TaskExecutionStatus.RUNNING_EXECUTION);
taskKillResponseCommand.setTaskInstanceId(1);
taskKillResponse.setHost("localhost");
taskKillResponse.setProcessId(1);
taskKillResponse.setStatus(TaskExecutionStatus.RUNNING_EXECUTION);
taskKillResponse.setTaskInstanceId(1);
}
@Test
public void testProcess() {
Command command = taskKillResponseCommand.convert2Command();
Assertions.assertEquals(CommandType.TASK_KILL_RESPONSE, command.getType());
taskKillResponseProcessor.process(channel, command);
Message message = taskKillResponse.convert2Command(1);
Assertions.assertEquals(MessageType.TASK_KILL_RESPONSE, message.getType());
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.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.remote.command.TaskExecuteResultCommand;
import org.apache.dolphinscheduler.remote.command.TaskExecuteRunningCommand;
import org.apache.dolphinscheduler.remote.command.task.TaskExecuteResultMessage;
import org.apache.dolphinscheduler.remote.command.task.TaskExecuteRunningMessage;
import org.apache.dolphinscheduler.server.master.cache.impl.ProcessInstanceExecCacheManagerImpl;
import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThreadPool;
import org.apache.dolphinscheduler.server.master.utils.DataQualityResultOperator;
@ -71,7 +71,7 @@ public class TaskResponseServiceTest {
public void before() {
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",
System.currentTimeMillis());
taskExecuteRunningMessage.setProcessId(1);
@ -86,7 +86,7 @@ public class TaskResponseServiceTest {
channel,
taskExecuteRunningMessage.getMessageSenderAddress());
TaskExecuteResultCommand taskExecuteResultMessage = new TaskExecuteResultCommand(NetUtils.getAddr(1234),
TaskExecuteResultMessage taskExecuteResultMessage = new TaskExecuteResultMessage(NetUtils.getAddr(1234),
NetUtils.getAddr(5678),
System.currentTimeMillis());
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.NettyEncoder;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.config.NettyClientConfig;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
import org.apache.dolphinscheduler.remote.exceptions.RemotingTimeoutException;
@ -142,7 +141,7 @@ public class NettyRemotingClient implements AutoCloseable {
* @param timeoutMillis timeoutMillis
* @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 InvokeCallback invokeCallback) throws InterruptedException, RemotingException {
final Channel channel = getChannel(host);
@ -201,19 +200,19 @@ public class NettyRemotingClient implements AutoCloseable {
* sync send
*
* @param host host
* @param command command
* @param message command
* @param timeoutMillis timeoutMillis
* @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 Channel channel = getChannel(host);
if (channel == null) {
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);
channel.writeAndFlush(command).addListener(future -> {
channel.writeAndFlush(message).addListener(future -> {
if (future.isSuccess()) {
responseFuture.setSendOk(true);
return;
@ -222,12 +221,12 @@ public class NettyRemotingClient implements AutoCloseable {
}
responseFuture.setCause(future.cause());
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
*/
Command result = responseFuture.waitResponse();
Message result = responseFuture.waitResponse();
if (result == null) {
if (responseFuture.isSendOK()) {
throw new RemotingTimeoutException(host.toString(), timeoutMillis, responseFuture.getCause());
@ -242,51 +241,49 @@ public class NettyRemotingClient implements AutoCloseable {
* send task
*
* @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);
if (channel == null) {
throw new RemotingException(String.format("connect to : %s fail", host));
}
try {
ChannelFuture future = channel.writeAndFlush(command).await();
ChannelFuture future = channel.writeAndFlush(message).await();
if (future.isSuccess()) {
log.debug("send command : {} , to : {} successfully.", command, host.getAddress());
log.debug("send command : {} , to : {} successfully.", message, host.getAddress());
} 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());
throw new RemotingException(msg);
}
} catch (RemotingException remotingException) {
throw remotingException;
} 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(
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
*
* @param commandType command type
* @param processor processor
*/
public void registerProcessor(final CommandType commandType, final NettyRequestProcessor processor) {
this.registerProcessor(commandType, processor, null);
public void registerProcessor(final NettyRequestProcessor processor) {
this.registerProcessor(processor, null);
}
/**
* register processor
*
* @param commandType command type
* @param processor processor
* @param executor thread executor
*/
public void registerProcessor(final CommandType commandType, final NettyRequestProcessor processor,
public void registerProcessor(final NettyRequestProcessor processor,
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.NettyEncoder;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.config.NettyServerConfig;
import org.apache.dolphinscheduler.remote.exceptions.RemoteException;
import org.apache.dolphinscheduler.remote.handler.NettyServerHandler;
@ -171,23 +170,21 @@ public class NettyRemotingServer {
/**
* register processor
*
* @param commandType command type
* @param processor processor
*/
public void registerProcessor(final CommandType commandType, final NettyRequestProcessor processor) {
this.registerProcessor(commandType, processor, null);
public void registerProcessor(final NettyRequestProcessor processor) {
this.registerProcessor(processor, null);
}
/**
* register processor
*
* @param commandType command type
* @param processor processor
* @param executor thread executor
*/
public void registerProcessor(final CommandType commandType, final NettyRequestProcessor processor,
public void registerProcessor(final NettyRequestProcessor processor,
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;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandContext;
import org.apache.dolphinscheduler.remote.command.CommandHeader;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.command.MessageContext;
import org.apache.dolphinscheduler.remote.command.MessageHeader;
import org.apache.dolphinscheduler.remote.command.MessageType;
import java.util.List;
@ -39,7 +39,7 @@ public class NettyDecoder extends ReplayingDecoder<NettyDecoder.State> {
super(State.MAGIC);
}
private final CommandHeader commandHeader = new CommandHeader();
private final MessageHeader messageHeader = new MessageHeader();
/**
* decode
@ -60,35 +60,35 @@ public class NettyDecoder extends ReplayingDecoder<NettyDecoder.State> {
checkpoint(State.COMMAND);
// fallthru
case COMMAND:
commandHeader.setType(in.readByte());
messageHeader.setType(in.readByte());
checkpoint(State.OPAQUE);
// fallthru
case OPAQUE:
commandHeader.setOpaque(in.readLong());
messageHeader.setOpaque(in.readLong());
checkpoint(State.CONTEXT_LENGTH);
// fallthru
case CONTEXT_LENGTH:
commandHeader.setContextLength(in.readInt());
messageHeader.setContextLength(in.readInt());
checkpoint(State.CONTEXT);
// fallthru
case CONTEXT:
byte[] context = new byte[commandHeader.getContextLength()];
byte[] context = new byte[messageHeader.getContextLength()];
in.readBytes(context);
commandHeader.setContext(context);
messageHeader.setContext(context);
checkpoint(State.BODY_LENGTH);
// fallthru
case BODY_LENGTH:
commandHeader.setBodyLength(in.readInt());
messageHeader.setBodyLength(in.readInt());
checkpoint(State.BODY);
// fallthru
case BODY:
byte[] body = new byte[commandHeader.getBodyLength()];
byte[] body = new byte[messageHeader.getBodyLength()];
in.readBytes(body);
//
Command packet = new Command();
packet.setType(commandType(commandHeader.getType()));
packet.setOpaque(commandHeader.getOpaque());
packet.setContext(CommandContext.valueOf(commandHeader.getContext()));
Message packet = new Message();
packet.setType(commandType(messageHeader.getType()));
packet.setOpaque(messageHeader.getOpaque());
packet.setContext(MessageContext.valueOf(messageHeader.getContext()));
packet.setBody(body);
out.add(packet);
//
@ -104,8 +104,8 @@ public class NettyDecoder extends ReplayingDecoder<NettyDecoder.State> {
*
* @param type type
*/
private CommandType commandType(byte type) {
for (CommandType ct : CommandType.values()) {
private MessageType commandType(byte type) {
for (MessageType ct : MessageType.values()) {
if (ct.ordinal() == type) {
return ct;
}
@ -119,7 +119,7 @@ public class NettyDecoder extends ReplayingDecoder<NettyDecoder.State> {
* @param magic magic
*/
private void checkMagic(byte magic) {
if (magic != Command.MAGIC) {
if (magic != Message.MAGIC) {
throw new IllegalArgumentException("illegal packet [magic]" + magic);
}
}
@ -128,7 +128,7 @@ public class NettyDecoder extends ReplayingDecoder<NettyDecoder.State> {
* check version
*/
private void checkVersion(byte version) {
if (version != Command.VERSION) {
if (version != Message.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;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
import io.netty.buffer.ByteBuf;
@ -29,7 +29,7 @@ import io.netty.handler.codec.MessageToByteEncoder;
* netty encoder
*/
@Sharable
public class NettyEncoder extends MessageToByteEncoder<Command> {
public class NettyEncoder extends MessageToByteEncoder<Message> {
/**
* encode
@ -39,12 +39,12 @@ public class NettyEncoder extends MessageToByteEncoder<Command> {
* @param out byte buffer
*/
@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) {
throw new RemotingException("encode msg is null");
}
out.writeByte(Command.MAGIC);
out.writeByte(Command.VERSION);
out.writeByte(Message.MAGIC);
out.writeByte(Message.VERSION);
out.writeByte(msg.getType().ordinal());
out.writeLong(msg.getOpaque());
writeContext(msg, out);
@ -52,7 +52,7 @@ public class NettyEncoder extends MessageToByteEncoder<Command> {
out.writeBytes(msg.getBody());
}
private void writeContext(Command msg, ByteBuf out) {
private void writeContext(Message msg, ByteBuf out) {
byte[] headerBytes = msg.getContext().toBytes();
out.writeInt(headerBytes.length);
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
@NoArgsConstructor
public abstract class BaseCommand implements Serializable {
public abstract class BaseMessage implements Serializable, RequestMessageBuilder {
private static final long serialVersionUID = -1L;
@ -49,7 +49,7 @@ public abstract class BaseCommand implements Serializable {
protected long messageSendTime;
protected BaseCommand(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) {
protected BaseMessage(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) {
this.messageSenderAddress = messageSenderAddress;
this.messageReceiverAddress = messageReceiverAddress;
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
* for netty data serializable transfer
*/
public class Command implements Serializable {
public class Message implements Serializable {
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 VERSION = 0;
public Command() {
public Message() {
this.opaque = REQUEST_ID.getAndIncrement();
}
public Command(long opaque) {
public Message(long opaque) {
this.opaque = opaque;
}
/**
* command type
*/
private CommandType type;
private MessageType type;
/**
* request unique identification
@ -54,18 +54,18 @@ public class Command implements Serializable {
/**
* request context
*/
private CommandContext context = new CommandContext();
private MessageContext context = new MessageContext();
/**
* data body
*/
private byte[] body;
public CommandType getType() {
public MessageType getType() {
return type;
}
public void setType(CommandType type) {
public void setType(MessageType type) {
this.type = type;
}
@ -85,11 +85,11 @@ public class Command implements Serializable {
this.body = body;
}
public CommandContext getContext() {
public MessageContext getContext() {
return context;
}
public void setContext(CommandContext context) {
public void setContext(MessageContext context) {
this.context = context;
}
@ -112,7 +112,7 @@ public class Command implements Serializable {
if (getClass() != obj.getClass()) {
return false;
}
Command other = (Command) obj;
Message other = (Message) obj;
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
*/
public class CommandContext implements Serializable {
public class MessageContext implements Serializable {
private Map<String, String> items = new LinkedHashMap<>();
@ -50,7 +50,7 @@ public class CommandContext implements Serializable {
return JSONUtils.toJsonByteArray(this);
}
public static CommandContext valueOf(byte[] src) {
return JSONUtils.parseObject(src, CommandContext.class);
public static MessageContext valueOf(byte[] src) {
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
*/
@Data
public class CommandHeader implements Serializable {
public class MessageHeader implements Serializable {
/**
* 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;
public enum CommandType {
public enum MessageType {
GET_APP_ID_REQUEST,
GET_APP_ID_RESPONSE,
@ -49,27 +49,27 @@ public enum CommandType {
/**
* dispatch task request
*/
TASK_DISPATCH_REQUEST,
TASK_DISPATCH_MESSAGE,
/**
* 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,
TASK_EXECUTE_RUNNING_MESSAGE_ACK,
/**
* task execute response, from worker to master
*/
TASK_EXECUTE_RESULT,
TASK_EXECUTE_RESULT_MESSAGE,
/**
* task execute response ack, from master to worker
*/
TASK_EXECUTE_RESULT_ACK,
TASK_EXECUTE_RESULT_MESSAGE_ACK,
TASK_KILL_REQUEST,
@ -77,7 +77,7 @@ public enum CommandType {
TASK_REJECT,
TASK_REJECT_ACK,
TASK_REJECT_MESSAGE_ACK,
/**
* task savepoint, for stream task
@ -127,12 +127,12 @@ public enum CommandType {
/**
* update taskInstance's PID request
*/
TASK_UPDATE_PID,
TASK_UPDATE_PID_MESSAGE,
/**
* 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

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;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.remote.utils.JsonSerializer;
import java.io.Serializable;
import lombok.Data;
public interface RequestMessageBuilder extends Serializable {
@Data
public class WorkflowMetricsCleanUpCommand implements Serializable {
private String processDefinitionCode;
/**
* 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;
default Message convert2Command() {
Message message = new Message();
message.setType(getCommandType());
byte[] body = JsonSerializer.serialize(this);
message.setBody(body);
return message;
}
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.
*/
package org.apache.dolphinscheduler.remote.command.alert;
import java.io.Serializable;
package org.apache.dolphinscheduler.remote.command;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* db task final result response command
*/
@Data
@NoArgsConstructor
@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;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.utils.JsonSerializer;
import java.io.Serializable;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -30,7 +27,7 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AlertSendRequestCommand implements Serializable {
public class AlertSendRequest implements RequestMessageBuilder {
private int groupId;
@ -40,16 +37,8 @@ public class AlertSendRequestCommand implements Serializable {
private int warnType;
/**
* package request command
*
* @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;
@Override
public MessageType getCommandType() {
return MessageType.ALERT_SEND_REQUEST;
}
}

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

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

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;
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 org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -33,23 +30,15 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RemoveTaskLogRequestCommand implements Serializable {
public class RemoveTaskLogRequest implements RequestMessageBuilder {
/**
* log path
*/
private String path;
/**
* package request command
*
* @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;
@Override
public MessageType getCommandType() {
return MessageType.REMOVE_TAK_LOG_REQUEST;
}
}

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;
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 org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.ResponseMessageBuilder;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -33,23 +30,15 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RemoveTaskLogResponseCommand implements Serializable {
public class RemoveTaskLogResponse implements ResponseMessageBuilder {
/*
* TaskPriorityQueueConsumer.* log path
*/
private Boolean status;
/**
* package request command
*
* @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;
@Override
public MessageType getCommandType() {
return MessageType.REMOVE_TAK_LOG_RESPONSE;
}
}

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;
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 org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -33,7 +30,7 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RollViewLogRequestCommand implements Serializable {
public class RollViewLogRequest implements RequestMessageBuilder {
/**
* log path
@ -50,16 +47,8 @@ public class RollViewLogRequestCommand implements Serializable {
*/
private int limit;
/**
* package request command
*
* @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;
@Override
public MessageType getCommandType() {
return MessageType.ROLL_VIEW_LOG_REQUEST;
}
}

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;
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 org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.ResponseMessageBuilder;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -33,24 +30,15 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RollViewLogResponseCommand implements Serializable {
public class RollViewLogResponse implements ResponseMessageBuilder {
/**
* 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.ROLL_VIEW_LOG_RESPONSE);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
@Override
public MessageType getCommandType() {
return MessageType.ROLL_VIEW_LOG_RESPONSE;
}
}

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;
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 org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -33,23 +30,15 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ViewLogRequestCommand implements Serializable {
public class ViewLogRequest implements RequestMessageBuilder {
/**
* log path
*/
private String path;
/**
* package request command
*
* @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;
@Override
public MessageType getCommandType() {
return MessageType.VIEW_WHOLE_LOG_REQUEST;
}
}

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.
*/
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.remote.command.BaseMessage;
import org.apache.dolphinscheduler.remote.command.MessageType;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -32,13 +33,13 @@ import lombok.ToString;
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class TaskDispatchCommand extends BaseCommand {
public class TaskDispatchMessage extends BaseMessage {
private static final long serialVersionUID = -1L;
private TaskExecutionContext taskExecutionContext;
public TaskDispatchCommand(TaskExecutionContext taskExecutionContext,
public TaskDispatchMessage(TaskExecutionContext taskExecutionContext,
String messageSenderAddress,
String messageReceiverAddress,
long messageSendTime) {
@ -46,12 +47,9 @@ public class TaskDispatchCommand extends BaseCommand {
this.taskExecutionContext = taskExecutionContext;
}
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.TASK_DISPATCH_REQUEST);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
@Override
public MessageType getCommandType() {
return MessageType.TASK_DISPATCH_MESSAGE;
}
}

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.
*/
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.EqualsAndHashCode;
@ -31,9 +32,9 @@ import lombok.ToString;
@NoArgsConstructor
@ToString(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);
}
@ -92,16 +93,8 @@ public class TaskExecuteResultCommand extends BaseCommand {
*/
private String varPool;
/**
* package response command
*
* @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;
@Override
public MessageType getCommandType() {
return MessageType.TASK_EXECUTE_RESULT_MESSAGE;
}
}

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.
*/
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.EqualsAndHashCode;
@ -32,12 +33,12 @@ import lombok.ToString;
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class TaskExecuteAckCommand extends BaseCommand {
public class TaskExecuteResultMessageAck extends BaseMessage {
private int taskInstanceId;
private boolean success;
public TaskExecuteAckCommand(boolean success,
public TaskExecuteResultMessageAck(boolean success,
int taskInstanceId,
String sourceServerAddress,
String messageReceiverAddress,
@ -47,16 +48,8 @@ public class TaskExecuteAckCommand extends BaseCommand {
this.taskInstanceId = taskInstanceId;
}
/**
* 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;
@Override
public MessageType getCommandType() {
return MessageType.TASK_EXECUTE_RESULT_MESSAGE_ACK;
}
}

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.
*/
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.remote.command.BaseMessage;
import org.apache.dolphinscheduler.remote.command.MessageType;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -32,7 +33,7 @@ import lombok.ToString;
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class TaskExecuteRunningCommand extends BaseCommand {
public class TaskExecuteRunningMessage extends BaseMessage {
/**
* taskInstanceId
@ -79,21 +80,13 @@ public class TaskExecuteRunningCommand extends BaseCommand {
*/
private String appIds;
public TaskExecuteRunningCommand(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) {
public TaskExecuteRunningMessage(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) {
super(messageSenderAddress, messageReceiverAddress, messageSendTime);
}
/**
* package request command
*
* @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;
@Override
public MessageType getCommandType() {
return MessageType.TASK_EXECUTE_RUNNING_MESSAGE;
}
}

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.
*/
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;
@ -33,7 +34,7 @@ import lombok.ToString;
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class TaskExecuteStartCommand extends BaseCommand {
public class TaskExecuteStartMessage extends BaseMessage {
private int executorId;
@ -57,21 +58,13 @@ public class TaskExecuteStartCommand extends BaseCommand {
private int dryRun;
public TaskExecuteStartCommand(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) {
public TaskExecuteStartMessage(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) {
super(messageSenderAddress, messageReceiverAddress, messageSendTime);
}
/**
* package request command
*
* @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;
@Override
public MessageType getCommandType() {
return MessageType.TASK_EXECUTE_START;
}
}

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

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.
*/
package org.apache.dolphinscheduler.remote.command;
package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import java.io.Serializable;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -31,23 +30,15 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TaskKillRequestCommand implements Serializable {
public class TaskKillRequest implements RequestMessageBuilder {
/**
* task id
*/
private int taskInstanceId;
/**
* package request command
*
* @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;
@Override
public MessageType getCommandType() {
return MessageType.TASK_KILL_REQUEST;
}
}

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.
*/
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.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.ResponseMessageBuilder;
import java.io.Serializable;
import java.util.List;
import lombok.AllArgsConstructor;
@ -35,7 +35,7 @@ import lombok.NoArgsConstructor;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TaskKillResponseCommand implements Serializable {
public class TaskKillResponse implements ResponseMessageBuilder {
private int taskInstanceId;
@ -50,17 +50,8 @@ public class TaskKillResponseCommand implements Serializable {
*/
private List<String> appIds;
/**
* package request command
*
* @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;
@Override
public MessageType getCommandType() {
return MessageType.TASK_KILL_RESPONSE;
}
}

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.
*/
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.EqualsAndHashCode;
@ -31,7 +32,7 @@ import lombok.ToString;
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class TaskRejectCommand extends BaseCommand {
public class TaskRejectMessage extends BaseMessage {
/**
* taskInstanceId
@ -48,20 +49,12 @@ public class TaskRejectCommand extends BaseCommand {
*/
private int processInstanceId;
public TaskRejectCommand(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) {
public TaskRejectMessage(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) {
super(messageSenderAddress, messageReceiverAddress, messageSendTime);
}
/**
* package request command
*
* @return command
*/
public Command convert2Command() {
Command command = new Command();
command.setType(CommandType.TASK_REJECT);
byte[] body = JSONUtils.toJsonByteArray(this);
command.setBody(body);
return command;
@Override
public MessageType getCommandType() {
return MessageType.TASK_REJECT;
}
}

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.
*/
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.EqualsAndHashCode;
@ -28,12 +29,12 @@ import lombok.ToString;
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class TaskRejectAckCommand extends BaseCommand {
public class TaskRejectMessageAck extends BaseMessage {
private int taskInstanceId;
private boolean success;
public TaskRejectAckCommand(boolean success,
public TaskRejectMessageAck(boolean success,
int taskInstanceId,
String messageSenderAddress,
String messageReceiverAddress,
@ -43,17 +44,9 @@ public class TaskRejectAckCommand extends BaseCommand {
this.taskInstanceId = taskInstanceId;
}
/**
* package response command
*
* @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;
@Override
public MessageType getCommandType() {
return MessageType.TASK_REJECT_MESSAGE_ACK;
}
}

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.
*/
package org.apache.dolphinscheduler.remote.command;
package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import java.io.Serializable;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -31,23 +30,15 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TaskSavePointRequestCommand implements Serializable {
public class TaskSavePointRequest implements RequestMessageBuilder {
/**
* task id
*/
private int taskInstanceId;
/**
* package request command
*
* @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;
@Override
public MessageType getCommandType() {
return MessageType.TASK_SAVEPOINT_REQUEST;
}
}

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.
*/
package org.apache.dolphinscheduler.remote.command;
package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import java.io.Serializable;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -31,23 +30,15 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TaskSavePointResponseCommand implements Serializable {
public class TaskSavePointResponse implements RequestMessageBuilder {
/**
* taskInstanceId
*/
private int taskInstanceId;
/**
* package request command
*
* @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;
@Override
public MessageType getCommandType() {
return MessageType.TASK_SAVEPOINT_RESPONSE;
}
}

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.
*/
package org.apache.dolphinscheduler.remote.command;
package org.apache.dolphinscheduler.remote.command.task;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import java.io.Serializable;
import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.RequestMessageBuilder;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -34,22 +33,14 @@ import lombok.NoArgsConstructor;
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class TaskUpdatePidAckMessage implements Serializable {
public class TaskUpdatePidAckMessage implements RequestMessageBuilder {
private boolean success;
private int taskInstanceId;
/**
* package response command
*
* @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;
@Override
public MessageType getCommandType() {
return MessageType.TASK_UPDATE_PID__MESSAGE_ACK;
}
}

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.
*/
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.EqualsAndHashCode;
@ -31,7 +32,7 @@ import lombok.ToString;
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class TaskUpdatePidCommand extends BaseCommand {
public class TaskUpdatePidMessage extends BaseMessage {
/**
* taskInstanceId
@ -63,21 +64,13 @@ public class TaskUpdatePidCommand extends BaseCommand {
*/
private int processId;
public TaskUpdatePidCommand(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) {
public TaskUpdatePidMessage(String messageSenderAddress, String messageReceiverAddress, long messageSendTime) {
super(messageSenderAddress, messageReceiverAddress, messageSendTime);
}
/**
* package request command
*
* @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;
@Override
public MessageType getCommandType() {
return MessageType.TASK_UPDATE_PID_MESSAGE;
}
}

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