You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by we...@apache.org on 2023/03/29 09:55:07 UTC
[dolphinscheduler] branch dev updated: Refactor remote command (#13809)
This is an automated email from the ASF dual-hosted git repository.
wenjun pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 68660ec96b Refactor remote command (#13809)
68660ec96b is described below
commit 68660ec96b20f431b5df7a34f691a9564493a245
Author: Wenjun Ruan <we...@apache.org>
AuthorDate: Wed Mar 29 17:54:57 2023 +0800
Refactor remote command (#13809)
* Refactor remote command
* Rename Command to Message
---
.../alert/AlertRequestProcessor.java | 35 ++-
.../dolphinscheduler/alert/AlertSenderService.java | 20 +-
.../apache/dolphinscheduler/alert/AlertServer.java | 32 +--
.../dolphinscheduler/alert/AlertServerTest.java | 92 --------
.../alert/processor/AlertRequestProcessorTest.java | 60 -----
.../alert/runner/AlertSenderServiceTest.java | 32 +--
.../api/aspect/CacheEvictAspect.java | 4 +-
.../instance/pause/pause/PauseExecuteFunction.java | 6 +-
.../instance/stop/StopExecuteFunction.java | 6 +-
.../dolphinscheduler/api/rpc/ApiRpcClient.java | 6 +-
.../api/service/impl/ExecutorServiceImpl.java | 59 ++---
.../service/impl/MetricsCleanUpServiceImpl.java | 8 +-
.../api/service/impl/TaskInstanceServiceImpl.java | 8 +-
.../api/service/ExecuteFunctionServiceTest.java | 5 +
.../master/consumer/TaskPriorityQueueConsumer.java | 10 +-
.../server/master/dispatch/ExecutorDispatcher.java | 2 +-
.../master/dispatch/context/ExecutionContext.java | 12 +-
.../dispatch/executor/NettyExecutorManager.java | 37 ++-
.../server/master/event/TaskDelayEventHandler.java | 20 +-
.../event/TaskRejectByWorkerEventHandler.java | 6 +-
.../master/event/TaskResultEventHandler.java | 4 +-
.../master/event/TaskRunningEventHandler.java | 17 +-
.../server/master/event/TaskStateEventHandler.java | 7 +-
.../master/event/TaskUpdatePidEventHandler.java | 2 +-
.../server/master/processor/CacheProcessor.java | 31 +--
.../master/processor/StateEventProcessor.java | 45 ++--
...cessor.java => TaskExecuteResultProcessor.java} | 25 +-
.../processor/TaskExecuteRunningProcessor.java | 22 +-
.../processor/TaskExecuteStartProcessor.java | 34 +--
...Processor.java => TaskForceStartProcessor.java} | 26 +--
.../processor/TaskKillResponseProcessor.java | 22 +-
.../master/processor/TaskRecallProcessor.java | 20 +-
.../master/processor/TaskUpdatePidProcessor.java | 28 +--
...ventProcessor.java => TaskWakeupProcessor.java} | 24 +-
.../WorkflowExecutingDataRequestProcessor.java | 27 +--
.../processor/WorkflowMetricsCleanUpProcessor.java | 23 +-
.../processor/queue/StateEventResponseService.java | 4 +-
.../server/master/processor/queue/TaskEvent.java | 16 +-
.../server/master/rpc/MasterRPCServer.java | 76 +------
.../server/master/rpc/MasterRpcClient.java | 8 +-
.../master/runner/StreamTaskExecuteRunnable.java | 33 +--
.../master/runner/WorkflowExecuteRunnable.java | 14 +-
.../master/runner/WorkflowExecuteThreadPool.java | 6 +-
.../master/runner/task/CommonTaskProcessor.java | 4 +-
.../master/runner/task/SubTaskProcessor.java | 6 +-
...sterCommandTest.java => MasterMessageTest.java} | 4 +-
.../master/dispatch/ExecutionContextTestUtils.java | 10 +-
.../master/dispatch/ExecutorDispatcherTest.java | 4 +-
.../executor/NettyExecutorManagerTest.java | 12 +-
.../master/processor/CacheProcessorTest.java | 10 +-
.../master/processor/TaskAckProcessorTest.java | 6 +-
.../processor/TaskKillResponseProcessorTest.java | 26 +--
.../processor/queue/TaskResponseServiceTest.java | 8 +-
.../remote/NettyRemotingClient.java | 41 ++--
.../remote/NettyRemotingServer.java | 15 +-
.../remote/codec/NettyDecoder.java | 40 ++--
.../remote/codec/NettyEncoder.java | 12 +-
.../command/{BaseCommand.java => BaseMessage.java} | 4 +-
.../remote/command/CacheExpireCommand.java | 67 ------
.../remote/command/{Command.java => Message.java} | 20 +-
.../{CommandContext.java => MessageContext.java} | 6 +-
.../{CommandHeader.java => MessageHeader.java} | 2 +-
.../command/{CommandType.java => MessageType.java} | 18 +-
...anUpCommand.java => RequestMessageBuilder.java} | 27 +--
...mandHeader.java => ResponseMessageBuilder.java} | 42 +---
...ResponseResult.java => StateEventResponse.java} | 18 +-
.../remote/command/StateEventResponseCommand.java | 49 ----
.../command/TaskStateEventResponseCommand.java | 42 ----
...ndRequestCommand.java => AlertSendRequest.java} | 23 +-
...ResponseCommand.java => AlertSendResponse.java} | 33 +--
.../CacheExpireRequest.java} | 16 +-
...pIdRequestCommand.java => GetAppIdRequest.java} | 18 +-
...dResponseCommand.java => GetAppIdResponse.java} | 17 +-
.../GetLogBytesRequest.java} | 21 +-
.../command/log/GetLogBytesRequestCommand.java | 55 -----
.../GetLogBytesResponse.java} | 20 +-
.../command/log/GetLogBytesResponseCommand.java | 57 -----
...questCommand.java => RemoveTaskLogRequest.java} | 23 +-
...onseCommand.java => RemoveTaskLogResponse.java} | 25 +-
...RequestCommand.java => RollViewLogRequest.java} | 23 +-
...sponseCommand.java => RollViewLogResponse.java} | 24 +-
...wLogRequestCommand.java => ViewLogRequest.java} | 23 +-
.../remote/command/log/ViewLogResponseCommand.java | 56 -----
.../ViewLogResponseResponse.java} | 21 +-
.../TaskDispatchMessage.java} | 18 +-
.../TaskExecuteResultMessage.java} | 23 +-
.../TaskExecuteResultMessageAck.java} | 31 +--
.../TaskExecuteRunningMessage.java} | 23 +-
.../TaskExecuteRunningMessageAck.java} | 37 ++-
.../TaskExecuteStartMessage.java} | 23 +-
.../TaskForceStartRequest.java} | 39 ++--
.../TaskKillRequest.java} | 23 +-
.../TaskKillResponse.java} | 23 +-
.../TaskRejectMessage.java} | 23 +-
.../TaskRejectMessageAck.java} | 23 +-
.../TaskSavePointRequest.java} | 23 +-
.../TaskSavePointResponse.java} | 23 +-
.../{ => task}/TaskUpdatePidAckMessage.java | 23 +-
.../TaskUpdatePidMessage.java} | 23 +-
.../TaskWakeupRequest.java} | 44 ++--
.../command/task/WorkflowHostChangeRequest.java | 23 +-
.../command/task/WorkflowHostChangeResponse.java | 18 +-
.../WorkflowExecutingDataRequest.java} | 23 +-
.../WorkflowExecutingDataResponse.java} | 23 +-
.../WorkflowMetricsCleanUpRequest.java} | 19 +-
.../WorkflowStateEventChangeRequest.java} | 26 +--
.../remote/future/ResponseFuture.java | 24 +-
.../remote/handler/NettyClientHandler.java | 48 ++--
.../remote/handler/NettyServerHandler.java | 30 +--
.../remote/processor/BaseLogProcessor.java | 137 +++++++++++
.../remote/processor/GetAppIdProcessor.java | 59 +++++
.../remote/processor/GetLogBytesProcessor.java | 50 ++++
.../remote/processor/LoggerRequestProcessor.java | 251 ---------------------
.../remote/processor/NettyRemoteChannel.java | 6 +-
.../remote/processor/NettyRequestProcessor.java | 9 +-
.../remote/processor/RemoveTaskLogProcessor.java | 62 +++++
.../remote/processor/RollViewLogRequest.java | 76 +++++++
.../processor/StateEventCallbackService.java | 20 +-
.../remote/processor/ViewWholeLogProcessor.java | 50 ++++
.../remote/utils/JsonSerializer.java | 26 ++-
.../remote/NettyRemotingClientTest.java | 66 +++---
...tCommandTest.java => AlertSendRequestTest.java} | 16 +-
...CommandTest.java => AlertSendResponseTest.java} | 23 +-
...ommandTest.java => CacheExpireRequestTest.java} | 13 +-
...ommandTest.java => GetLogBytesRequestTest.java} | 12 +-
...mmandTest.java => GetLogBytesResponseTest.java} | 10 +-
...mandTest.java => RemoveTaskLogRequestTest.java} | 12 +-
...andTest.java => RemoveTaskLogResponseTest.java} | 12 +-
.../command/log/RollViewLogRequestCommandTest.java | 36 ---
...ommandTest.java => RollViewLogRequestTest.java} | 15 +-
.../service/alert/AlertClientService.java | 29 +--
.../service/cache/CacheNotifyService.java | 4 +-
.../service/cache/impl/CacheNotifyServiceImpl.java | 10 +-
.../dolphinscheduler/service/log/LogClient.java | 72 +++---
.../service/process/ProcessService.java | 3 -
.../service/process/ProcessServiceImpl.java | 19 +-
.../service/alert/AlertClientServiceTest.java | 85 +++----
.../service/cache/CacheNotifyServiceTest.java | 26 ++-
...ceImplTest.java => MessageServiceImplTest.java} | 2 +-
.../service/log/LoggerRequestProcessorTest.java | 58 ++---
.../server/worker/message/MessageRetryRunner.java | 30 +--
.../server/worker/message/MessageSender.java | 8 +-
.../message/TaskExecuteResultMessageSender.java | 18 +-
.../message/TaskExecuteRunningMessageSender.java | 18 +-
.../worker/message/TaskRejectMessageSender.java | 16 +-
.../worker/message/TaskUpdatePidMessageSender.java | 28 +--
.../worker/processor/TaskDispatchProcessor.java | 34 +--
.../processor/TaskExecuteResultAckProcessor.java | 31 ++-
.../processor/TaskExecuteRunningAckProcessor.java | 23 +-
.../server/worker/processor/TaskKillProcessor.java | 51 ++---
.../worker/processor/TaskRejectAckProcessor.java | 36 +--
.../worker/processor/TaskSavePointProcessor.java | 43 ++--
.../processor/TaskUpdatePidAckProcessor.java | 20 +-
.../processor/WorkflowHostChangeProcessor.java | 19 +-
.../server/worker/rpc/WorkerMessageSender.java | 24 +-
.../server/worker/rpc/WorkerRpcClient.java | 37 +--
.../server/worker/rpc/WorkerRpcServer.java | 63 +-----
.../server/worker/runner/TaskCallbackImpl.java | 6 +-
.../worker/runner/WorkerTaskExecuteRunnable.java | 14 +-
.../processor/TaskDispatchProcessorTest.java | 16 +-
160 files changed, 1880 insertions(+), 2502 deletions(-)
diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertRequestProcessor.java b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertRequestProcessor.java
index a034e9586a..9a9caa9f82 100644
--- a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertRequestProcessor.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
index 8309ae9ae3..20ce32f7ff 100644
--- a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
+++ b/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);
}
/**
diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java
index 5c6f57508b..dd1e53bc17 100644
--- a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java
+++ b/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();
}
}
diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/AlertServerTest.java b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/AlertServerTest.java
deleted file mode 100644
index 171c8ccbc4..0000000000
--- a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/AlertServerTest.java
+++ /dev/null
@@ -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();
- }
- }
-}
diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/processor/AlertRequestProcessorTest.java b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/processor/AlertRequestProcessorTest.java
deleted file mode 100644
index 5ad6e26cdf..0000000000
--- a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/processor/AlertRequestProcessorTest.java
+++ /dev/null
@@ -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);
- }
-}
diff --git a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/runner/AlertSenderServiceTest.java b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/runner/AlertSenderServiceTest.java
index 371ea71f16..eb4183c0e0 100644
--- a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/test/java/org/apache/dolphinscheduler/alert/runner/AlertSenderServiceTest.java
+++ b/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()));
}
diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/aspect/CacheEvictAspect.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/aspect/CacheEvictAspect.java
index 8f3a057b7f..3d7a4c0afe 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/aspect/CacheEvictAspect.java
+++ b/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());
}
}
diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/executor/workflow/instance/pause/pause/PauseExecuteFunction.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/executor/workflow/instance/pause/pause/PauseExecuteFunction.java
index 83711660f8..0020e4df77 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/executor/workflow/instance/pause/pause/PauseExecuteFunction.java
+++ b/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(
diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/executor/workflow/instance/stop/StopExecuteFunction.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/executor/workflow/instance/stop/StopExecuteFunction.java
index 2e37423e9a..553f4ec661 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/executor/workflow/instance/stop/StopExecuteFunction.java
+++ b/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",
diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/rpc/ApiRpcClient.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/rpc/ApiRpcClient.java
index 17f24dc67e..f0c1ba6d6d 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/rpc/ApiRpcClient.java
+++ b/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);
}
}
diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
index 3f2a5f87df..ed491a6352 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
+++ b/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);
diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/MetricsCleanUpServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/MetricsCleanUpServiceImpl.java
index abea381251..20ac139065 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/MetricsCleanUpServiceImpl.java
+++ b/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 {}",
diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java
index 8ab4557635..f3d4f0e6e6 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java
+++ b/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);
diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecuteFunctionServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecuteFunctionServiceTest.java
index 21630b0e1d..2a00a6aa65 100644
--- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecuteFunctionServiceTest.java
+++ b/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);
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumer.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumer.java
index c28c01ee58..9a34ff1bb2 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumer.java
+++ b/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());
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutorDispatcher.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutorDispatcher.java
index 1880f9295f..f247e9db31 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutorDispatcher.java
+++ b/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);
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/context/ExecutionContext.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/context/ExecutionContext.java
index 3294f04a01..e0b49a531a 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/context/ExecutionContext.java
+++ b/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;
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManager.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManager.java
index 3df401f8fd..7ceb6e2977 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManager.java
+++ b/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));
}
}
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskDelayEventHandler.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskDelayEventHandler.java
index 6355e8278d..cc8000092b 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskDelayEventHandler.java
+++ b/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
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskRejectByWorkerEventHandler.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskRejectByWorkerEventHandler.java
index 77ac5e52a2..77c6f77f85 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskRejectByWorkerEventHandler.java
+++ b/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
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskResultEventHandler.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskResultEventHandler.java
index 1d4b221313..fb8a3fbc74 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskResultEventHandler.java
+++ b/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(),
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskRunningEventHandler.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskRunningEventHandler.java
index 5bfa75733d..3edb6c3006 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskRunningEventHandler.java
+++ b/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
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskStateEventHandler.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskStateEventHandler.java
index 7a6e0c3072..28c048d05c 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskStateEventHandler.java
+++ b/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());
- workflowExecuteRunnable.releaseTaskGroup(task);
+ try {
+ workflowExecuteRunnable.releaseTaskGroup(task);
+ } catch (RemotingException | InterruptedException e) {
+ throw new StateEventHandleException("Release task group failed", e);
+ }
}
return true;
}
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskUpdatePidEventHandler.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskUpdatePidEventHandler.java
index 1f81139ae2..3ade584ac9 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/event/TaskUpdatePidEventHandler.java
+++ b/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;
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/CacheProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/CacheProcessor.java
index b69937357a..3f6789a523 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/CacheProcessor.java
+++ b/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());
}
}
}
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/StateEventProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/StateEventProcessor.java
index 167aa156b7..d4a784f120 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/StateEventProcessor.java
+++ b/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();
}
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskExecuteResponseProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskExecuteResultProcessor.java
similarity index 75%
rename from dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskExecuteResponseProcessor.java
rename to dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskExecuteResultProcessor.java
index f40473e0f9..81436e3c70 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskExecuteResponseProcessor.java
+++ b/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;
+ }
}
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskExecuteRunningProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskExecuteRunningProcessor.java
index 1a1788f5df..55f15a31cf 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskExecuteRunningProcessor.java
+++ b/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;
+ }
+
}
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskExecuteStartProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskExecuteStartProcessor.java
index b9d302e2fb..63f07f5b3d 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskExecuteStartProcessor.java
+++ b/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;
+ }
+
}
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskEventProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskForceStartProcessor.java
similarity index 73%
copy from dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskEventProcessor.java
copy to dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskForceStartProcessor.java
index d4fa52445e..9185a0c700 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskEventProcessor.java
+++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskForceStartProcessor.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.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;
@@ -32,27 +32,19 @@ 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;
-/**
- * handle state event received from master/api
- */
@Component
@Slf4j
-public class TaskEventProcessor implements NettyRequestProcessor {
+public class TaskForceStartProcessor 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) {
+ TaskForceStartRequest taskEventChangeCommand =
+ JSONUtils.parseObject(message.getBody(), TaskForceStartRequest.class);
TaskStateEvent stateEvent = TaskStateEvent.builder()
.processInstanceId(taskEventChangeCommand.getProcessInstanceId())
.taskInstanceId(taskEventChangeCommand.getTaskInstanceId())
@@ -67,4 +59,8 @@ public class TaskEventProcessor implements NettyRequestProcessor {
}
}
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.TASK_FORCE_STATE_EVENT_REQUEST;
+ }
}
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskKillResponseProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskKillResponseProcessor.java
index 02ee30257a..c2c5b73ab2 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskKillResponseProcessor.java
+++ b/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;
+ }
+
}
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskRecallProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskRecallProcessor.java
index a903131c9f..9a8967a12f 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskRecallProcessor.java
+++ b/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;
+ }
}
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskUpdatePidProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskUpdatePidProcessor.java
index bca59a079f..414012900e 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskUpdatePidProcessor.java
+++ b/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;
+ }
+
}
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskEventProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskWakeupProcessor.java
similarity index 75%
rename from dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskEventProcessor.java
rename to dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskWakeupProcessor.java
index d4fa52445e..4799024e79 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskEventProcessor.java
+++ b/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;
+ }
+
}
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/WorkflowExecutingDataRequestProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/WorkflowExecutingDataRequestProcessor.java
index 6977789b5b..b3fb6f2518 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/WorkflowExecutingDataRequestProcessor.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/WorkflowMetricsCleanUpProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/WorkflowMetricsCleanUpProcessor.java
index 30254d63a8..ea08426266 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/WorkflowMetricsCleanUpProcessor.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java
index 41dc8948f2..bfa5d00945 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java
+++ b/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());
}
}
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskEvent.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskEvent.java
index 1d2827223c..5f2097f58d 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskEvent.java
+++ b/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());
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/rpc/MasterRPCServer.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/rpc/MasterRPCServer.java
index d039aac814..56df578461 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/rpc/MasterRPCServer.java
+++ b/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...");
}
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/rpc/MasterRpcClient.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/rpc/MasterRpcClient.java
index 4bc9788685..a8f587f347 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/rpc/MasterRpcClient.java
+++ b/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);
}
}
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/StreamTaskExecuteRunnable.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/StreamTaskExecuteRunnable.java
index 7ff33b1667..cda2310ef6 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/StreamTaskExecuteRunnable.java
+++ b/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 {
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteRunnable.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteRunnable.java
index 7f79ea6967..8930cba8af 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteRunnable.java
+++ b/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",
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThreadPool.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThreadPool.java
index 00a54cc5d9..6a62be507b 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThreadPool.java
+++ b/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());
}
}
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/CommonTaskProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/CommonTaskProcessor.java
index 4b63fb3ea7..068e8be084 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/CommonTaskProcessor.java
+++ b/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 =
diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/SubTaskProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/SubTaskProcessor.java
index 1f8f125b19..76d7356484 100644
--- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/SubTaskProcessor.java
+++ b/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
diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/MasterCommandTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/MasterMessageTest.java
similarity index 98%
rename from dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/MasterCommandTest.java
rename to dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/MasterMessageTest.java
index 3ab7781489..932aa1f865 100644
--- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/MasterCommandTest.java
+++ b/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;
diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutionContextTestUtils.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutionContextTestUtils.java
index b95356acc6..d2b56890b8 100644
--- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutionContextTestUtils.java
+++ b/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;
diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutorDispatcherTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutorDispatcherTest.java
index 20a8d2a9f7..ce1bef11f9 100644
--- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutorDispatcherTest.java
+++ b/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);
diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManagerTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManagerTest.java
index f5be1ed86f..f03ee3b4e0 100644
--- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManagerTest.java
+++ b/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());
diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/CacheProcessorTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/CacheProcessorTest.java
index ebddeb45d1..cf44b66ed7 100644
--- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/CacheProcessorTest.java
+++ b/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);
}
}
diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskAckProcessorTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskAckProcessorTest.java
index c0fe33a137..f5eaa4424d 100644
--- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskAckProcessorTest.java
+++ b/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);
diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskKillResponseProcessorTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskKillResponseProcessorTest.java
index 2626ed1eb7..6e94bcd8ac 100644
--- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskKillResponseProcessorTest.java
+++ b/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);
}
}
diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseServiceTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseServiceTest.java
index 4b9e37a601..92031ee824 100644
--- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseServiceTest.java
+++ b/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);
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/NettyRemotingClient.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/NettyRemotingClient.java
index d1f081617c..e92ffd4961 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/NettyRemotingClient.java
+++ b/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);
}
/**
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/NettyRemotingServer.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/NettyRemotingServer.java
index 8480dbd301..740910a9a5 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/NettyRemotingServer.java
+++ b/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
+ * @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);
}
/**
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/codec/NettyDecoder.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/codec/NettyDecoder.java
index 2881d3c91c..f7bb944b5e 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/codec/NettyDecoder.java
+++ b/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);
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/codec/NettyEncoder.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/codec/NettyEncoder.java
index c1d6e0fcd2..d6e10cf126 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/codec/NettyEncoder.java
+++ b/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);
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/BaseCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/BaseMessage.java
similarity index 93%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/BaseCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/BaseMessage.java
index 8207b5fecc..a5d73c26b6 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/BaseCommand.java
+++ b/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;
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CacheExpireCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CacheExpireCommand.java
deleted file mode 100644
index a32d4fce13..0000000000
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CacheExpireCommand.java
+++ /dev/null
@@ -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);
- }
-}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/Command.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/Message.java
similarity index 86%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/Command.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/Message.java
index 28c36e56fb..767cc483fd 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/Command.java
+++ b/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;
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CommandContext.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/MessageContext.java
similarity index 89%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CommandContext.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/MessageContext.java
index c9febee6fc..f53a3771a3 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CommandContext.java
+++ b/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);
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CommandHeader.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/MessageHeader.java
similarity index 95%
copy from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CommandHeader.java
copy to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/MessageHeader.java
index 32eb75dc90..271b5dec62 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CommandHeader.java
+++ b/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
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CommandType.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/MessageType.java
similarity index 90%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CommandType.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/MessageType.java
index 997de50638..7c432a11e7 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CommandType.java
+++ b/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
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/WorkflowMetricsCleanUpCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/RequestMessageBuilder.java
similarity index 62%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/WorkflowMetricsCleanUpCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/RequestMessageBuilder.java
index 337bd05333..dc816ec951 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/WorkflowMetricsCleanUpCommand.java
+++ b/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();
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CommandHeader.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/ResponseMessageBuilder.java
similarity index 67%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CommandHeader.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/ResponseMessageBuilder.java
index 32eb75dc90..3b208a4fcd 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/CommandHeader.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/ResponseMessageBuilder.java
@@ -17,39 +17,19 @@
package org.apache.dolphinscheduler.remote.command;
-import java.io.Serializable;
-
-import lombok.Data;
-
-/**
- * command header
- */
-@Data
-public class CommandHeader implements Serializable {
+import org.apache.dolphinscheduler.remote.utils.JsonSerializer;
- /**
- * type
- */
- private byte type;
-
- /**
- * request unique identification
- */
- private long opaque;
-
- /**
- * context length
- */
- private int contextLength;
+import java.io.Serializable;
- /**
- * context
- */
- private byte[] context;
+public interface ResponseMessageBuilder extends Serializable {
- /**
- * body length
- */
- private int bodyLength;
+ 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();
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/StateEventResponse.java
similarity index 73%
copy from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java
copy to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/StateEventResponse.java
index 7b2fd98edd..aa9abca9c1 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java
+++ b/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;
+ }
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/StateEventResponseCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/StateEventResponseCommand.java
deleted file mode 100644
index 6b21e1acd6..0000000000
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/StateEventResponseCommand.java
+++ /dev/null
@@ -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;
- }
-
-}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskStateEventResponseCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskStateEventResponseCommand.java
deleted file mode 100644
index 0a0ba0b012..0000000000
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskStateEventResponseCommand.java
+++ /dev/null
@@ -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;
- }
-}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendRequestCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendRequest.java
similarity index 64%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendRequestCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendRequest.java
index 5bc4154d9c..68e29f4c28 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendRequestCommand.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponse.java
similarity index 65%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponse.java
index 6d729e7539..452bef5a00 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseCommand.java
+++ b/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;
+
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/cache/CacheExpireRequest.java
similarity index 66%
copy from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java
copy to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/cache/CacheExpireRequest.java
index 7b2fd98edd..76c63dd87d 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/cache/CacheExpireRequest.java
@@ -15,9 +15,11 @@
* limitations under the License.
*/
-package org.apache.dolphinscheduler.remote.command.alert;
+package org.apache.dolphinscheduler.remote.command.cache;
-import java.io.Serializable;
+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;
@@ -26,10 +28,14 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
-public class AlertSendResponseResult implements Serializable {
+public class CacheExpireRequest implements RequestMessageBuilder {
- private boolean success;
+ private CacheType cacheType;
+ private String cacheKey;
- private String message;
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.CACHE_EXPIRE;
+ }
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetAppIdRequestCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetAppIdRequest.java
similarity index 67%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetAppIdRequestCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetAppIdRequest.java
index e980143dac..8eebb8a354 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetAppIdRequestCommand.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetAppIdResponseCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetAppIdResponse.java
similarity index 66%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetAppIdResponseCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetAppIdResponse.java
index 0952cfb1ba..c4f8afa6f0 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetAppIdResponseCommand.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesRequest.java
similarity index 66%
copy from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java
copy to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesRequest.java
index 7b2fd98edd..23916f140a 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesRequest.java
@@ -15,21 +15,30 @@
* limitations under the License.
*/
-package org.apache.dolphinscheduler.remote.command.alert;
+package org.apache.dolphinscheduler.remote.command.log;
-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;
+/**
+ * get log bytes request command
+ */
@Data
@NoArgsConstructor
@AllArgsConstructor
-public class AlertSendResponseResult implements Serializable {
-
- private boolean success;
+public class GetLogBytesRequest implements RequestMessageBuilder {
- private String message;
+ /**
+ * log path
+ */
+ private String path;
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.GET_LOG_BYTES_REQUEST;
+ }
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesRequestCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesRequestCommand.java
deleted file mode 100644
index de73e26861..0000000000
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesRequestCommand.java
+++ /dev/null
@@ -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;
- }
-}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponse.java
similarity index 66%
copy from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java
copy to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponse.java
index 7b2fd98edd..03335ecd95 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponse.java
@@ -15,21 +15,31 @@
* limitations under the License.
*/
-package org.apache.dolphinscheduler.remote.command.alert;
+package org.apache.dolphinscheduler.remote.command.log;
-import java.io.Serializable;
+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 AlertSendResponseResult implements Serializable {
+public class GetLogBytesResponse implements ResponseMessageBuilder {
- private boolean success;
+ /**
+ * log byte data
+ */
+ private byte[] data;
- private String message;
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.GET_LOG_BYTES_RESPONSE;
+ }
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponseCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponseCommand.java
deleted file mode 100644
index 3ba4cf3b58..0000000000
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponseCommand.java
+++ /dev/null
@@ -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;
- }
-
-}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogRequestCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogRequest.java
similarity index 64%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogRequestCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogRequest.java
index 8dc8f274d8..4c958614ca 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogRequestCommand.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogResponseCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogResponse.java
similarity index 62%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogResponseCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogResponse.java
index 6e0ae320a6..332f845796 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogResponseCommand.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogResponse.java
@@ -17,39 +17,28 @@
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;
import lombok.NoArgsConstructor;
/**
- * remove task log request command
+ * remove task log request command
*/
@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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogRequestCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogRequest.java
similarity index 67%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogRequestCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogRequest.java
index e4075f6cf7..2438c3dc58 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogRequestCommand.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogResponseCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogResponse.java
similarity index 62%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogResponseCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogResponse.java
index 71be7a0cf3..afd05c85a5 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogResponseCommand.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/ViewLogRequestCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/ViewLogRequest.java
similarity index 64%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/ViewLogRequestCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/ViewLogRequest.java
index a4b3c4749b..4a1c48c900 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/ViewLogRequestCommand.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/ViewLogResponseCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/ViewLogResponseCommand.java
deleted file mode 100644
index e9a368ad7c..0000000000
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/ViewLogResponseCommand.java
+++ /dev/null
@@ -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;
- }
-}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/ViewLogResponseResponse.java
similarity index 66%
copy from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java
copy to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/ViewLogResponseResponse.java
index 7b2fd98edd..cedc6a549a 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/log/ViewLogResponseResponse.java
@@ -15,21 +15,30 @@
* limitations under the License.
*/
-package org.apache.dolphinscheduler.remote.command.alert;
+package org.apache.dolphinscheduler.remote.command.log;
-import java.io.Serializable;
+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 AlertSendResponseResult implements Serializable {
-
- private boolean success;
+public class ViewLogResponseResponse implements ResponseMessageBuilder {
- private String message;
+ /**
+ * response data
+ */
+ private String msg;
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.VIEW_WHOLE_LOG_RESPONSE;
+ }
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskDispatchCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskDispatchMessage.java
similarity index 76%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskDispatchCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskDispatchMessage.java
index bf9abe8c96..ac95891051 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskDispatchCommand.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteResultCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteResultMessage.java
similarity index 77%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteResultCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteResultMessage.java
index 42d99672e0..5a326a501e 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteResultCommand.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteAckCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteResultMessageAck.java
similarity index 62%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteAckCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteResultMessageAck.java
index 4505031a23..109eb1498e 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteAckCommand.java
+++ b/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,31 +33,23 @@ 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,
- int taskInstanceId,
- String sourceServerAddress,
- String messageReceiverAddress,
- long messageSendTime) {
+ public TaskExecuteResultMessageAck(boolean success,
+ int taskInstanceId,
+ String sourceServerAddress,
+ String messageReceiverAddress,
+ long messageSendTime) {
super(sourceServerAddress, messageReceiverAddress, messageSendTime);
this.success = success;
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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteRunningCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteRunningMessage.java
similarity index 77%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteRunningCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteRunningMessage.java
index c02ea64849..9556686bcc 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteRunningCommand.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskRejectAckCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteRunningMessageAck.java
similarity index 61%
copy from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskRejectAckCommand.java
copy to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteRunningMessageAck.java
index 9fe9edf492..21733add5b 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskRejectAckCommand.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteRunningMessageAck.java
@@ -15,45 +15,42 @@
* 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;
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 TaskRejectAckCommand extends BaseCommand {
+public class TaskExecuteRunningMessageAck extends BaseMessage {
- private int taskInstanceId;
private boolean success;
+ private int taskInstanceId;
- public TaskRejectAckCommand(boolean success,
- int taskInstanceId,
- String messageSenderAddress,
- String messageReceiverAddress,
- long messageSendTime) {
+ public TaskExecuteRunningMessageAck(boolean success,
+ int taskInstanceId,
+ String messageSenderAddress,
+ String messageReceiverAddress,
+ long messageSendTime) {
super(messageSenderAddress, messageReceiverAddress, messageSendTime);
this.success = success;
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_EXECUTE_RUNNING_MESSAGE_ACK;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteStartCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteStartMessage.java
similarity index 74%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteStartCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskExecuteStartMessage.java
index 80f63652eb..5b8530186a 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteStartCommand.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskEventChangeCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskForceStartRequest.java
similarity index 56%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskEventChangeCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskForceStartRequest.java
index adfcaa105a..56499065db 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskEventChangeCommand.java
+++ b/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(
- int processInstanceId,
- int taskInstanceId) {
- this.key = String.format("%d-%d",
- processInstanceId,
- taskInstanceId);
+ public TaskForceStartRequest(
+ int processInstanceId,
+ int 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;
}
-
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskKillRequestCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskKillRequest.java
similarity index 66%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskKillRequestCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskKillRequest.java
index 7dc03d778c..e11ba53a8b 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskKillRequestCommand.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskKillResponseCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskKillResponse.java
similarity index 71%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskKillResponseCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskKillResponse.java
index 7f92b41543..e99d6c56d5 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskKillResponseCommand.java
+++ b/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;
}
-
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskRejectCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskRejectMessage.java
similarity index 72%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskRejectCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskRejectMessage.java
index a9ce5c56a7..58ae5b0380 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskRejectCommand.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskRejectAckCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskRejectMessageAck.java
similarity index 73%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskRejectAckCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskRejectMessageAck.java
index 9fe9edf492..98bab90953 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskRejectAckCommand.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskSavePointRequestCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskSavePointRequest.java
similarity index 66%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskSavePointRequestCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskSavePointRequest.java
index 8a1dfae6da..5ea8a4f70b 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskSavePointRequestCommand.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskSavePointResponseCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskSavePointResponse.java
similarity index 66%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskSavePointResponseCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskSavePointResponse.java
index 55eb272eb3..9e992787ee 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskSavePointResponseCommand.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskUpdatePidAckMessage.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskUpdatePidAckMessage.java
similarity index 67%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskUpdatePidAckMessage.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskUpdatePidAckMessage.java
index 4f878c5c55..317bcee188 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskUpdatePidAckMessage.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskUpdatePidCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskUpdatePidMessage.java
similarity index 74%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskUpdatePidCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskUpdatePidMessage.java
index 91e5787bd5..056ad891d6 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskUpdatePidCommand.java
+++ b/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;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteRunningAckMessage.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskWakeupRequest.java
similarity index 56%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteRunningAckMessage.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/TaskWakeupRequest.java
index 120867977b..3a21d5b32f 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/TaskExecuteRunningAckMessage.java
+++ b/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;
+ }
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/WorkflowHostChangeRequest.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/WorkflowHostChangeRequest.java
index 1a480e247f..50b23d40b3 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/WorkflowHostChangeRequest.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/WorkflowHostChangeRequest.java
@@ -17,11 +17,8 @@
package org.apache.dolphinscheduler.remote.command.task;
-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,22 +27,14 @@ import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
-public class WorkflowHostChangeRequest implements Serializable {
+public class WorkflowHostChangeRequest implements RequestMessageBuilder {
private int taskInstanceId;
private String workflowHost;
- /**
- * package request command
- *
- * @return command
- */
- public Command convert2Command() {
- Command command = new Command();
- command.setType(CommandType.WORKFLOW_HOST_CHANGE_REQUEST);
- byte[] body = JSONUtils.toJsonByteArray(this);
- command.setBody(body);
- return command;
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.WORKFLOW_HOST_CHANGE_REQUEST;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/WorkflowHostChangeResponse.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/WorkflowHostChangeResponse.java
index 5ce58f2aa2..16acf034cd 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/WorkflowHostChangeResponse.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/task/WorkflowHostChangeResponse.java
@@ -17,11 +17,8 @@
package org.apache.dolphinscheduler.remote.command.task;
-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;
@@ -30,7 +27,7 @@ import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
-public class WorkflowHostChangeResponse implements Serializable {
+public class WorkflowHostChangeResponse implements ResponseMessageBuilder {
boolean success;
@@ -46,11 +43,8 @@ public class WorkflowHostChangeResponse implements Serializable {
return response;
}
- public Command convert2Command(long opaque) {
- Command command = new Command(opaque);
- command.setType(CommandType.WORKFLOW_HOST_CHANGE_RESPONSE);
- byte[] body = JSONUtils.toJsonByteArray(this);
- command.setBody(body);
- return command;
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.WORKFLOW_HOST_CHANGE_RESPONSE;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/WorkflowExecutingDataRequestCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/workflow/WorkflowExecutingDataRequest.java
similarity index 65%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/WorkflowExecutingDataRequestCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/workflow/WorkflowExecutingDataRequest.java
index 6085322831..9a6285bb0a 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/WorkflowExecutingDataRequestCommand.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/workflow/WorkflowExecutingDataRequest.java
@@ -15,11 +15,10 @@
* limitations under the License.
*/
-package org.apache.dolphinscheduler.remote.command;
+package org.apache.dolphinscheduler.remote.command.workflow;
-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,20 +30,12 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
-public class WorkflowExecutingDataRequestCommand implements Serializable {
+public class WorkflowExecutingDataRequest implements RequestMessageBuilder {
private Integer processInstanceId;
- /**
- * package request command
- *
- * @return command
- */
- public Command convert2Command() {
- Command command = new Command();
- command.setType(CommandType.WORKFLOW_EXECUTING_DATA_REQUEST);
- byte[] body = JSONUtils.toJsonByteArray(this);
- command.setBody(body);
- return command;
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.WORKFLOW_EXECUTING_DATA_REQUEST;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/WorkflowExecutingDataResponseCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/workflow/WorkflowExecutingDataResponse.java
similarity index 66%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/WorkflowExecutingDataResponseCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/workflow/WorkflowExecutingDataResponse.java
index 2d2dfa20b0..adc8a6633a 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/WorkflowExecutingDataResponseCommand.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/workflow/WorkflowExecutingDataResponse.java
@@ -15,13 +15,12 @@
* limitations under the License.
*/
-package org.apache.dolphinscheduler.remote.command;
+package org.apache.dolphinscheduler.remote.command.workflow;
-import org.apache.dolphinscheduler.common.utils.JSONUtils;
+import org.apache.dolphinscheduler.remote.command.MessageType;
+import org.apache.dolphinscheduler.remote.command.ResponseMessageBuilder;
import org.apache.dolphinscheduler.remote.dto.WorkflowExecuteDto;
-import java.io.Serializable;
-
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -32,20 +31,12 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
-public class WorkflowExecutingDataResponseCommand implements Serializable {
+public class WorkflowExecutingDataResponse implements ResponseMessageBuilder {
private WorkflowExecuteDto workflowExecuteDto;
- /**
- * package request command
- *
- * @return command
- */
- public Command convert2Command(long opaque) {
- Command command = new Command(opaque);
- command.setType(CommandType.WORKFLOW_EXECUTING_DATA_RESPONSE);
- byte[] body = JSONUtils.toJsonByteArray(this);
- command.setBody(body);
- return command;
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.WORKFLOW_EXECUTING_DATA_RESPONSE;
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/workflow/WorkflowMetricsCleanUpRequest.java
similarity index 65%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/workflow/WorkflowMetricsCleanUpRequest.java
index 7b2fd98edd..4faf09f123 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseResult.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/workflow/WorkflowMetricsCleanUpRequest.java
@@ -15,21 +15,20 @@
* limitations under the License.
*/
-package org.apache.dolphinscheduler.remote.command.alert;
+package org.apache.dolphinscheduler.remote.command.workflow;
-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;
@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class AlertSendResponseResult implements Serializable {
+public class WorkflowMetricsCleanUpRequest implements RequestMessageBuilder {
- private boolean success;
-
- private String message;
+ private String processDefinitionCode;
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.WORKFLOW_METRICS_CLEANUP;
+ }
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/WorkflowStateEventChangeCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/workflow/WorkflowStateEventChangeRequest.java
similarity index 77%
rename from dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/WorkflowStateEventChangeCommand.java
rename to dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/workflow/WorkflowStateEventChangeRequest.java
index def9f663ed..b8b771c84e 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/WorkflowStateEventChangeCommand.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/workflow/WorkflowStateEventChangeRequest.java
@@ -15,12 +15,11 @@
* limitations under the License.
*/
-package org.apache.dolphinscheduler.remote.command;
+package org.apache.dolphinscheduler.remote.command.workflow;
import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
-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.Data;
import lombok.NoArgsConstructor;
@@ -30,7 +29,7 @@ import lombok.NoArgsConstructor;
*/
@Data
@NoArgsConstructor
-public class WorkflowStateEventChangeCommand implements Serializable {
+public class WorkflowStateEventChangeRequest implements RequestMessageBuilder {
private String key;
@@ -44,7 +43,7 @@ public class WorkflowStateEventChangeCommand implements Serializable {
private int destTaskInstanceId;
- public WorkflowStateEventChangeCommand(int sourceProcessInstanceId,
+ public WorkflowStateEventChangeRequest(int sourceProcessInstanceId,
int sourceTaskInstanceId,
WorkflowExecutionStatus sourceStatus,
int destProcessInstanceId,
@@ -62,17 +61,8 @@ public class WorkflowStateEventChangeCommand implements Serializable {
this.destTaskInstanceId = destTaskInstanceId;
}
- /**
- * package response command
- *
- * @return command
- */
- public Command convert2Command() {
- Command command = new Command();
- command.setType(CommandType.STATE_EVENT_REQUEST);
- byte[] body = JSONUtils.toJsonByteArray(this);
- command.setBody(body);
- return command;
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.STATE_EVENT_REQUEST;
}
-
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/future/ResponseFuture.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/future/ResponseFuture.java
index c21669cbcf..ea56190d10 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/future/ResponseFuture.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/future/ResponseFuture.java
@@ -17,7 +17,7 @@
package org.apache.dolphinscheduler.remote.future;
-import org.apache.dolphinscheduler.remote.command.Command;
+import org.apache.dolphinscheduler.remote.command.Message;
import java.util.Iterator;
import java.util.LinkedList;
@@ -64,7 +64,7 @@ public class ResponseFuture {
/**
* response command
*/
- private Command responseCommand;
+ private Message responseMessage;
private volatile boolean sendOk = true;
@@ -84,18 +84,18 @@ public class ResponseFuture {
*
* @return command
*/
- public Command waitResponse() throws InterruptedException {
+ public Message waitResponse() throws InterruptedException {
this.latch.await(timeoutMillis, TimeUnit.MILLISECONDS);
- return this.responseCommand;
+ return this.responseMessage;
}
/**
* put response
*
- * @param responseCommand responseCommand
+ * @param responseMessage responseCommand
*/
- public void putResponse(final Command responseCommand) {
- this.responseCommand = responseCommand;
+ public void putResponse(final Message responseMessage) {
+ this.responseMessage = responseMessage;
this.latch.countDown();
FUTURE_TABLE.remove(opaque);
}
@@ -155,12 +155,12 @@ public class ResponseFuture {
return beginTimestamp;
}
- public Command getResponseCommand() {
- return responseCommand;
+ public Message getResponseCommand() {
+ return responseMessage;
}
- public void setResponseCommand(Command responseCommand) {
- this.responseCommand = responseCommand;
+ public void setResponseCommand(Message responseMessage) {
+ this.responseMessage = responseMessage;
}
public InvokeCallback getInvokeCallback() {
@@ -210,7 +210,7 @@ public class ResponseFuture {
+ ", releaseSemaphore=" + releaseSemaphore
+ ", latch=" + latch
+ ", beginTimestamp=" + beginTimestamp
- + ", responseCommand=" + responseCommand
+ + ", responseCommand=" + responseMessage
+ ", sendOk=" + sendOk
+ ", cause=" + cause
+ '}';
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/handler/NettyClientHandler.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/handler/NettyClientHandler.java
index b1b9229c58..7dfa37f447 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/handler/NettyClientHandler.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/handler/NettyClientHandler.java
@@ -18,8 +18,8 @@
package org.apache.dolphinscheduler.remote.handler;
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.command.MessageType;
import org.apache.dolphinscheduler.remote.future.ResponseFuture;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.remote.utils.ChannelUtils;
@@ -61,7 +61,7 @@ public class NettyClientHandler extends ChannelInboundHandlerAdapter {
/**
* processors
*/
- private final ConcurrentHashMap<CommandType, Pair<NettyRequestProcessor, ExecutorService>> processors;
+ private final ConcurrentHashMap<MessageType, Pair<NettyRequestProcessor, ExecutorService>> processors;
/**
* default executor
@@ -94,74 +94,74 @@ public class NettyClientHandler extends ChannelInboundHandlerAdapter {
*/
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
- processReceived(ctx.channel(), (Command) msg);
+ processReceived(ctx.channel(), (Message) msg);
}
/**
* register processor
*
- * @param commandType command type
+ * @param messageType command type
* @param processor processor
*/
- public void registerProcessor(final CommandType commandType, final NettyRequestProcessor processor) {
- this.registerProcessor(commandType, processor, null);
+ public void registerProcessor(final MessageType messageType, final NettyRequestProcessor processor) {
+ this.registerProcessor(messageType, processor, null);
}
/**
* register processor
*
- * @param commandType command type
+ * @param messageType command type
* @param processor processor
* @param executor thread executor
*/
- public void registerProcessor(final CommandType commandType, final NettyRequestProcessor processor,
+ public void registerProcessor(final MessageType messageType, final NettyRequestProcessor processor,
final ExecutorService executor) {
ExecutorService executorRef = executor;
if (executorRef == null) {
executorRef = defaultExecutor;
}
- this.processors.putIfAbsent(commandType, new Pair<>(processor, executorRef));
+ this.processors.putIfAbsent(messageType, new Pair<>(processor, executorRef));
}
/**
* process received logic
*
- * @param command command
+ * @param message command
*/
- private void processReceived(final Channel channel, final Command command) {
- ResponseFuture future = ResponseFuture.getFuture(command.getOpaque());
+ private void processReceived(final Channel channel, final Message message) {
+ ResponseFuture future = ResponseFuture.getFuture(message.getOpaque());
if (future != null) {
- future.setResponseCommand(command);
+ future.setResponseCommand(message);
future.release();
if (future.getInvokeCallback() != null) {
future.removeFuture();
this.callbackExecutor.submit(future::executeInvokeCallback);
} else {
- future.putResponse(command);
+ future.putResponse(message);
}
} else {
- processByCommandType(channel, command);
+ processByCommandType(channel, message);
}
}
- public void processByCommandType(final Channel channel, final Command command) {
- final Pair<NettyRequestProcessor, ExecutorService> pair = processors.get(command.getType());
+ public void processByCommandType(final Channel channel, final Message message) {
+ final Pair<NettyRequestProcessor, ExecutorService> pair = processors.get(message.getType());
if (pair != null) {
Runnable run = () -> {
try {
- pair.getLeft().process(channel, command);
+ pair.getLeft().process(channel, message);
} catch (Exception e) {
- log.error(String.format("process command %s exception", command), e);
+ log.error(String.format("process command %s exception", message), e);
}
};
try {
pair.getRight().submit(run);
} catch (RejectedExecutionException e) {
- log.warn("thread pool is full, discard command {} from {}", command,
+ log.warn("thread pool is full, discard command {} from {}", message,
ChannelUtils.getRemoteAddress(channel));
}
} else {
- log.warn("receive response {}, but not matched any request ", command);
+ log.warn("receive response {}, but not matched any request ", message);
}
}
@@ -181,8 +181,8 @@ public class NettyClientHandler extends ChannelInboundHandlerAdapter {
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof IdleStateEvent) {
- Command heartBeat = new Command();
- heartBeat.setType(CommandType.HEART_BEAT);
+ Message heartBeat = new Message();
+ heartBeat.setType(MessageType.HEART_BEAT);
heartBeat.setBody(heartBeatData);
ctx.channel().writeAndFlush(heartBeat)
.addListener(ChannelFutureListener.CLOSE_ON_FAILURE);
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/handler/NettyServerHandler.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/handler/NettyServerHandler.java
index 103e27dc89..788c593ba3 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/handler/NettyServerHandler.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/handler/NettyServerHandler.java
@@ -18,8 +18,8 @@
package org.apache.dolphinscheduler.remote.handler;
import org.apache.dolphinscheduler.remote.NettyRemotingServer;
-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.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.remote.utils.ChannelUtils;
import org.apache.dolphinscheduler.remote.utils.Pair;
@@ -51,7 +51,7 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
/**
* server processors queue
*/
- private final ConcurrentHashMap<CommandType, Pair<NettyRequestProcessor, ExecutorService>> processors =
+ private final ConcurrentHashMap<MessageType, Pair<NettyRequestProcessor, ExecutorService>> processors =
new ConcurrentHashMap<>();
public NettyServerHandler(NettyRemotingServer nettyRemotingServer) {
@@ -77,33 +77,33 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
*/
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
- processReceived(ctx.channel(), (Command) msg);
+ processReceived(ctx.channel(), (Message) msg);
}
/**
* register processor
*
- * @param commandType command type
+ * @param messageType command type
* @param processor processor
*/
- public void registerProcessor(final CommandType commandType, final NettyRequestProcessor processor) {
- this.registerProcessor(commandType, processor, null);
+ public void registerProcessor(final MessageType messageType, final NettyRequestProcessor processor) {
+ this.registerProcessor(messageType, processor, null);
}
/**
* register processor
*
- * @param commandType command type
+ * @param messageType command type
* @param processor processor
* @param executor thread executor
*/
- public void registerProcessor(final CommandType commandType, final NettyRequestProcessor processor,
+ public void registerProcessor(final MessageType messageType, final NettyRequestProcessor processor,
final ExecutorService executor) {
ExecutorService executorRef = executor;
if (executorRef == null) {
executorRef = nettyRemotingServer.getDefaultExecutor();
}
- this.processors.putIfAbsent(commandType, new Pair<>(processor, executorRef));
+ this.processors.putIfAbsent(messageType, new Pair<>(processor, executorRef));
}
/**
@@ -112,15 +112,15 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
* @param channel channel
* @param msg message
*/
- private void processReceived(final Channel channel, final Command msg) {
- final CommandType commandType = msg.getType();
- if (CommandType.HEART_BEAT.equals(commandType)) {
+ private void processReceived(final Channel channel, final Message msg) {
+ final MessageType messageType = msg.getType();
+ if (MessageType.HEART_BEAT.equals(messageType)) {
if (log.isDebugEnabled()) {
log.debug("server receive heart beat from: host: {}", ChannelUtils.getRemoteAddress(channel));
}
return;
}
- final Pair<NettyRequestProcessor, ExecutorService> pair = processors.get(commandType);
+ final Pair<NettyRequestProcessor, ExecutorService> pair = processors.get(messageType);
if (pair != null) {
Runnable r = () -> {
try {
@@ -135,7 +135,7 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
log.warn("thread pool is full, discard msg {} from {}", msg, ChannelUtils.getRemoteAddress(channel));
}
} else {
- log.warn("commandType {} not support", commandType);
+ log.warn("commandType {} not support", messageType);
}
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/BaseLogProcessor.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/BaseLogProcessor.java
new file mode 100644
index 0000000000..d5b5af49bc
--- /dev/null
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/BaseLogProcessor.java
@@ -0,0 +1,137 @@
+/*
+ * 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.processor;
+
+import org.apache.dolphinscheduler.common.log.remote.RemoteLogUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public abstract class BaseLogProcessor {
+
+ /**
+ * get files content bytes for download file
+ *
+ * @param filePath file path
+ * @return byte array of file
+ */
+ protected byte[] getFileContentBytesFromLocal(String filePath) {
+ try (
+ InputStream in = new FileInputStream(filePath);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) != -1) {
+ bos.write(buf, 0, len);
+ }
+ return bos.toByteArray();
+ } catch (IOException e) {
+ log.error("get file bytes error", e);
+ }
+ return new byte[0];
+ }
+
+ protected byte[] getFileContentBytesFromRemote(String filePath) {
+ RemoteLogUtils.getRemoteLog(filePath);
+ return getFileContentBytesFromLocal(filePath);
+ }
+
+ protected byte[] getFileContentBytes(String filePath) {
+ File file = new File(filePath);
+ if (file.exists()) {
+ return getFileContentBytesFromLocal(filePath);
+ }
+ if (RemoteLogUtils.isRemoteLoggingEnable()) {
+ return getFileContentBytesFromRemote(filePath);
+ }
+ return getFileContentBytesFromLocal(filePath);
+ }
+
+ /**
+ * read part file content,can skip any line and read some lines
+ *
+ * @param filePath file path
+ * @param skipLine skip line
+ * @param limit read lines limit
+ * @return part file content
+ */
+ protected List<String> readPartFileContentFromLocal(String filePath,
+ int skipLine,
+ int limit) {
+ File file = new File(filePath);
+ if (file.exists() && file.isFile()) {
+ try (Stream<String> stream = Files.lines(Paths.get(filePath))) {
+ return stream.skip(skipLine).limit(limit).collect(Collectors.toList());
+ } catch (IOException e) {
+ log.error("read file error", e);
+ throw new RuntimeException(String.format("Read file: %s error", filePath), e);
+ }
+ } else {
+ throw new RuntimeException("The file path: " + filePath + " not exists");
+ }
+ }
+
+ protected List<String> readPartFileContentFromRemote(String filePath,
+ int skipLine,
+ int limit) {
+ RemoteLogUtils.getRemoteLog(filePath);
+ return readPartFileContentFromLocal(filePath, skipLine, limit);
+ }
+
+ protected List<String> readPartFileContent(String filePath,
+ int skipLine,
+ int limit) {
+ File file = new File(filePath);
+ if (file.exists()) {
+ return readPartFileContentFromLocal(filePath, skipLine, limit);
+ }
+ if (RemoteLogUtils.isRemoteLoggingEnable()) {
+ return readPartFileContentFromRemote(filePath, skipLine, limit);
+ }
+ return readPartFileContentFromLocal(filePath, skipLine, limit);
+ }
+
+ protected String readWholeFileContentFromRemote(String filePath) {
+ RemoteLogUtils.getRemoteLog(filePath);
+ return LogUtils.readWholeFileContentFromLocal(filePath);
+ }
+
+ protected String readWholeFileContent(String filePath) {
+ File file = new File(filePath);
+ if (file.exists()) {
+ return LogUtils.readWholeFileContentFromLocal(filePath);
+ }
+ if (RemoteLogUtils.isRemoteLoggingEnable()) {
+ return readWholeFileContentFromRemote(filePath);
+ }
+ return LogUtils.readWholeFileContentFromLocal(filePath);
+ }
+
+}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/GetAppIdProcessor.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/GetAppIdProcessor.java
new file mode 100644
index 0000000000..6c446aacb1
--- /dev/null
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/GetAppIdProcessor.java
@@ -0,0 +1,59 @@
+/*
+ * 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.processor;
+
+import static org.apache.dolphinscheduler.common.constants.Constants.APPID_COLLECT;
+import static org.apache.dolphinscheduler.common.constants.Constants.DEFAULT_COLLECT_WAY;
+
+import org.apache.dolphinscheduler.common.utils.JSONUtils;
+import org.apache.dolphinscheduler.common.utils.PropertyUtils;
+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.log.GetAppIdRequest;
+import org.apache.dolphinscheduler.remote.command.log.GetAppIdResponse;
+
+import java.util.List;
+
+import lombok.extern.slf4j.Slf4j;
+
+import org.springframework.stereotype.Component;
+
+import io.netty.channel.Channel;
+
+@Component
+@Slf4j
+public class GetAppIdProcessor extends BaseLogProcessor implements NettyRequestProcessor {
+
+ @Override
+ public void process(Channel channel, Message message) {
+ GetAppIdRequest getAppIdRequest =
+ JSONUtils.parseObject(message.getBody(), GetAppIdRequest.class);
+ String appInfoPath = getAppIdRequest.getAppInfoPath();
+ String logPath = getAppIdRequest.getLogPath();
+ List<String> appIds = LogUtils.getAppIds(logPath, appInfoPath,
+ PropertyUtils.getString(APPID_COLLECT, DEFAULT_COLLECT_WAY));
+ channel.writeAndFlush(
+ new GetAppIdResponse(appIds).convert2Command(message.getOpaque()));
+ }
+
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.GET_APP_ID_REQUEST;
+ }
+}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/GetLogBytesProcessor.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/GetLogBytesProcessor.java
new file mode 100644
index 0000000000..19401e35c4
--- /dev/null
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/GetLogBytesProcessor.java
@@ -0,0 +1,50 @@
+/*
+ * 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.processor;
+
+import org.apache.dolphinscheduler.common.utils.JSONUtils;
+import org.apache.dolphinscheduler.remote.command.Message;
+import org.apache.dolphinscheduler.remote.command.MessageType;
+import org.apache.dolphinscheduler.remote.command.log.GetLogBytesRequest;
+import org.apache.dolphinscheduler.remote.command.log.GetLogBytesResponse;
+
+import lombok.extern.slf4j.Slf4j;
+
+import org.springframework.stereotype.Component;
+
+import io.netty.channel.Channel;
+
+@Component
+@Slf4j
+public class GetLogBytesProcessor extends BaseLogProcessor implements NettyRequestProcessor {
+
+ @Override
+ public void process(Channel channel, Message message) {
+ GetLogBytesRequest getLogRequest = JSONUtils.parseObject(
+ message.getBody(), GetLogBytesRequest.class);
+ String path = getLogRequest.getPath();
+ byte[] bytes = getFileContentBytes(path);
+ GetLogBytesResponse getLogResponse = new GetLogBytesResponse(bytes);
+ channel.writeAndFlush(getLogResponse.convert2Command(message.getOpaque()));
+ }
+
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.GET_LOG_BYTES_REQUEST;
+ }
+}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/LoggerRequestProcessor.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/LoggerRequestProcessor.java
deleted file mode 100644
index ff16ae253d..0000000000
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/LoggerRequestProcessor.java
+++ /dev/null
@@ -1,251 +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.processor;
-
-import static org.apache.dolphinscheduler.common.constants.Constants.APPID_COLLECT;
-import static org.apache.dolphinscheduler.common.constants.Constants.DEFAULT_COLLECT_WAY;
-
-import org.apache.dolphinscheduler.common.log.remote.RemoteLogUtils;
-import org.apache.dolphinscheduler.common.utils.JSONUtils;
-import org.apache.dolphinscheduler.common.utils.PropertyUtils;
-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.log.GetAppIdRequestCommand;
-import org.apache.dolphinscheduler.remote.command.log.GetAppIdResponseCommand;
-import org.apache.dolphinscheduler.remote.command.log.GetLogBytesRequestCommand;
-import org.apache.dolphinscheduler.remote.command.log.GetLogBytesResponseCommand;
-import org.apache.dolphinscheduler.remote.command.log.RemoveTaskLogRequestCommand;
-import org.apache.dolphinscheduler.remote.command.log.RemoveTaskLogResponseCommand;
-import org.apache.dolphinscheduler.remote.command.log.RollViewLogRequestCommand;
-import org.apache.dolphinscheduler.remote.command.log.RollViewLogResponseCommand;
-import org.apache.dolphinscheduler.remote.command.log.ViewLogRequestCommand;
-import org.apache.dolphinscheduler.remote.command.log.ViewLogResponseCommand;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import lombok.extern.slf4j.Slf4j;
-
-import org.springframework.stereotype.Component;
-
-import io.netty.channel.Channel;
-
-/**
- * logger request process logic
- */
-@Component
-@Slf4j
-public class LoggerRequestProcessor implements NettyRequestProcessor {
-
- @Override
- public void process(Channel channel, Command command) {
- log.info("received command : {}", command);
-
- // request task log command type
- final CommandType commandType = command.getType();
- switch (commandType) {
- case GET_LOG_BYTES_REQUEST:
- GetLogBytesRequestCommand getLogRequest = JSONUtils.parseObject(
- command.getBody(), GetLogBytesRequestCommand.class);
- String path = getLogRequest.getPath();
- byte[] bytes = getFileContentBytes(path);
- GetLogBytesResponseCommand getLogResponse = new GetLogBytesResponseCommand(bytes);
- channel.writeAndFlush(getLogResponse.convert2Command(command.getOpaque()));
- break;
- case VIEW_WHOLE_LOG_REQUEST:
- ViewLogRequestCommand viewLogRequest = JSONUtils.parseObject(
- command.getBody(), ViewLogRequestCommand.class);
- String viewLogPath = viewLogRequest.getPath();
- String msg = readWholeFileContent(viewLogPath);
- ViewLogResponseCommand viewLogResponse = new ViewLogResponseCommand(msg);
- channel.writeAndFlush(viewLogResponse.convert2Command(command.getOpaque()));
- break;
- case ROLL_VIEW_LOG_REQUEST:
- RollViewLogRequestCommand rollViewLogRequest = JSONUtils.parseObject(
- command.getBody(), RollViewLogRequestCommand.class);
-
- String rollViewLogPath = rollViewLogRequest.getPath();
-
- List<String> lines = readPartFileContent(rollViewLogPath,
- rollViewLogRequest.getSkipLineNum(), rollViewLogRequest.getLimit());
- StringBuilder builder = new StringBuilder();
- final int MaxResponseLogSize = 65535;
- int totalLogByteSize = 0;
- for (String line : lines) {
- // If a single line of log is exceed max response size, cut off the line
- final int lineByteSize = line.getBytes(StandardCharsets.UTF_8).length;
- if (lineByteSize >= MaxResponseLogSize) {
- builder.append(line, 0, MaxResponseLogSize)
- .append(" [this line's size ").append(lineByteSize).append(" bytes is exceed ")
- .append(MaxResponseLogSize).append(" bytes, so only ")
- .append(MaxResponseLogSize).append(" characters are reserved for performance reasons.]")
- .append("\r\n");
- } else {
- builder.append(line).append("\r\n");
- }
- totalLogByteSize += lineByteSize;
- if (totalLogByteSize >= MaxResponseLogSize) {
- break;
- }
- }
- RollViewLogResponseCommand rollViewLogRequestResponse =
- new RollViewLogResponseCommand(builder.toString());
- channel.writeAndFlush(rollViewLogRequestResponse.convert2Command(command.getOpaque()));
- break;
- case REMOVE_TAK_LOG_REQUEST:
- RemoveTaskLogRequestCommand removeTaskLogRequest = JSONUtils.parseObject(
- command.getBody(), RemoveTaskLogRequestCommand.class);
-
- String taskLogPath = removeTaskLogRequest.getPath();
- File taskLogFile = new File(taskLogPath);
- boolean status = true;
- try {
- if (taskLogFile.exists()) {
- status = taskLogFile.delete();
- }
- } catch (Exception e) {
- status = false;
- }
-
- RemoveTaskLogResponseCommand removeTaskLogResponse = new RemoveTaskLogResponseCommand(status);
- channel.writeAndFlush(removeTaskLogResponse.convert2Command(command.getOpaque()));
- break;
- case GET_APP_ID_REQUEST:
- GetAppIdRequestCommand getAppIdRequestCommand =
- JSONUtils.parseObject(command.getBody(), GetAppIdRequestCommand.class);
- String appInfoPath = getAppIdRequestCommand.getAppInfoPath();
- String logPath = getAppIdRequestCommand.getLogPath();
- List<String> appIds = LogUtils.getAppIds(logPath, appInfoPath,
- PropertyUtils.getString(APPID_COLLECT, DEFAULT_COLLECT_WAY));
- channel.writeAndFlush(
- new GetAppIdResponseCommand(appIds).convert2Command(command.getOpaque()));
- break;
- default:
- throw new IllegalArgumentException("unknown commandType: " + commandType);
- }
- }
-
- /**
- * get files content bytes for download file
- *
- * @param filePath file path
- * @return byte array of file
- */
- private byte[] getFileContentBytesFromLocal(String filePath) {
- try (
- InputStream in = new FileInputStream(filePath);
- ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
- byte[] buf = new byte[1024];
- int len;
- while ((len = in.read(buf)) != -1) {
- bos.write(buf, 0, len);
- }
- return bos.toByteArray();
- } catch (IOException e) {
- log.error("get file bytes error", e);
- }
- return new byte[0];
- }
-
- private byte[] getFileContentBytesFromRemote(String filePath) {
- RemoteLogUtils.getRemoteLog(filePath);
- return getFileContentBytesFromLocal(filePath);
- }
-
- private byte[] getFileContentBytes(String filePath) {
- File file = new File(filePath);
- if (file.exists()) {
- return getFileContentBytesFromLocal(filePath);
- }
- if (RemoteLogUtils.isRemoteLoggingEnable()) {
- return getFileContentBytesFromRemote(filePath);
- }
- return getFileContentBytesFromLocal(filePath);
- }
-
- /**
- * read part file content,can skip any line and read some lines
- *
- * @param filePath file path
- * @param skipLine skip line
- * @param limit read lines limit
- * @return part file content
- */
- private List<String> readPartFileContentFromLocal(String filePath,
- int skipLine,
- int limit) {
- File file = new File(filePath);
- if (file.exists() && file.isFile()) {
- try (Stream<String> stream = Files.lines(Paths.get(filePath))) {
- return stream.skip(skipLine).limit(limit).collect(Collectors.toList());
- } catch (IOException e) {
- log.error("read file error", e);
- throw new RuntimeException(String.format("Read file: %s error", filePath), e);
- }
- } else {
- throw new RuntimeException("The file path: " + filePath + " not exists");
- }
- }
-
- private List<String> readPartFileContentFromRemote(String filePath,
- int skipLine,
- int limit) {
- RemoteLogUtils.getRemoteLog(filePath);
- return readPartFileContentFromLocal(filePath, skipLine, limit);
- }
-
- private List<String> readPartFileContent(String filePath,
- int skipLine,
- int limit) {
- File file = new File(filePath);
- if (file.exists()) {
- return readPartFileContentFromLocal(filePath, skipLine, limit);
- }
- if (RemoteLogUtils.isRemoteLoggingEnable()) {
- return readPartFileContentFromRemote(filePath, skipLine, limit);
- }
- return readPartFileContentFromLocal(filePath, skipLine, limit);
- }
-
- private String readWholeFileContentFromRemote(String filePath) {
- RemoteLogUtils.getRemoteLog(filePath);
- return LogUtils.readWholeFileContentFromLocal(filePath);
- }
-
- private String readWholeFileContent(String filePath) {
- File file = new File(filePath);
- if (file.exists()) {
- return LogUtils.readWholeFileContentFromLocal(filePath);
- }
- if (RemoteLogUtils.isRemoteLoggingEnable()) {
- return readWholeFileContentFromRemote(filePath);
- }
- return LogUtils.readWholeFileContentFromLocal(filePath);
- }
-
-}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/NettyRemoteChannel.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/NettyRemoteChannel.java
index 4609c6d239..e4f7173f64 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/NettyRemoteChannel.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/NettyRemoteChannel.java
@@ -17,7 +17,7 @@
package org.apache.dolphinscheduler.remote.processor;
-import org.apache.dolphinscheduler.remote.command.Command;
+import org.apache.dolphinscheduler.remote.command.Message;
import org.apache.dolphinscheduler.remote.utils.ChannelUtils;
import org.apache.dolphinscheduler.remote.utils.Host;
@@ -72,8 +72,8 @@ public class NettyRemoteChannel {
return this.channel.isActive();
}
- public ChannelFuture writeAndFlush(Command command) {
- return this.channel.writeAndFlush(command);
+ public ChannelFuture writeAndFlush(Message message) {
+ return this.channel.writeAndFlush(message);
}
public void close() {
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/NettyRequestProcessor.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/NettyRequestProcessor.java
index d3e37f02ee..d731eddd60 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/NettyRequestProcessor.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/NettyRequestProcessor.java
@@ -16,7 +16,8 @@
*/
package org.apache.dolphinscheduler.remote.processor;
-import org.apache.dolphinscheduler.remote.command.Command;
+import org.apache.dolphinscheduler.remote.command.Message;
+import org.apache.dolphinscheduler.remote.command.MessageType;
import io.netty.channel.Channel;
@@ -28,7 +29,9 @@ public interface NettyRequestProcessor {
/**
* process logic
* @param channel channel
- * @param command command
+ * @param message command
*/
- void process(final Channel channel, final Command command);
+ void process(final Channel channel, final Message message);
+
+ MessageType getCommandType();
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/RemoveTaskLogProcessor.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/RemoveTaskLogProcessor.java
new file mode 100644
index 0000000000..e52366ada1
--- /dev/null
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/RemoveTaskLogProcessor.java
@@ -0,0 +1,62 @@
+/*
+ * 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.processor;
+
+import org.apache.dolphinscheduler.common.utils.JSONUtils;
+import org.apache.dolphinscheduler.remote.command.Message;
+import org.apache.dolphinscheduler.remote.command.MessageType;
+import org.apache.dolphinscheduler.remote.command.log.RemoveTaskLogRequest;
+import org.apache.dolphinscheduler.remote.command.log.RemoveTaskLogResponse;
+
+import java.io.File;
+
+import lombok.extern.slf4j.Slf4j;
+
+import org.springframework.stereotype.Component;
+
+import io.netty.channel.Channel;
+
+@Component
+@Slf4j
+public class RemoveTaskLogProcessor extends BaseLogProcessor implements NettyRequestProcessor {
+
+ @Override
+ public void process(Channel channel, Message message) {
+ RemoveTaskLogRequest removeTaskLogRequest = JSONUtils.parseObject(
+ message.getBody(), RemoveTaskLogRequest.class);
+
+ String taskLogPath = removeTaskLogRequest.getPath();
+ File taskLogFile = new File(taskLogPath);
+ boolean status = true;
+ try {
+ if (taskLogFile.exists()) {
+ status = taskLogFile.delete();
+ }
+ } catch (Exception e) {
+ status = false;
+ }
+
+ RemoveTaskLogResponse removeTaskLogResponse = new RemoveTaskLogResponse(status);
+ channel.writeAndFlush(removeTaskLogResponse.convert2Command(message.getOpaque()));
+ }
+
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.REMOVE_TAK_LOG_REQUEST;
+ }
+}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/RollViewLogRequest.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/RollViewLogRequest.java
new file mode 100644
index 0000000000..beeb7ec429
--- /dev/null
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/RollViewLogRequest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.processor;
+
+import org.apache.dolphinscheduler.common.utils.JSONUtils;
+import org.apache.dolphinscheduler.remote.command.Message;
+import org.apache.dolphinscheduler.remote.command.MessageType;
+import org.apache.dolphinscheduler.remote.command.log.RollViewLogResponse;
+
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+
+import lombok.extern.slf4j.Slf4j;
+
+import org.springframework.stereotype.Component;
+
+import io.netty.channel.Channel;
+
+@Component
+@Slf4j
+public class RollViewLogRequest extends BaseLogProcessor implements NettyRequestProcessor {
+
+ @Override
+ public void process(Channel channel, Message message) {
+ org.apache.dolphinscheduler.remote.command.log.RollViewLogRequest rollViewLogRequest = JSONUtils.parseObject(
+ message.getBody(), org.apache.dolphinscheduler.remote.command.log.RollViewLogRequest.class);
+
+ String rollViewLogPath = rollViewLogRequest.getPath();
+
+ List<String> lines = readPartFileContent(rollViewLogPath,
+ rollViewLogRequest.getSkipLineNum(), rollViewLogRequest.getLimit());
+ StringBuilder builder = new StringBuilder();
+ final int MaxResponseLogSize = 65535;
+ int totalLogByteSize = 0;
+ for (String line : lines) {
+ // If a single line of log is exceed max response size, cut off the line
+ final int lineByteSize = line.getBytes(StandardCharsets.UTF_8).length;
+ if (lineByteSize >= MaxResponseLogSize) {
+ builder.append(line, 0, MaxResponseLogSize)
+ .append(" [this line's size ").append(lineByteSize).append(" bytes is exceed ")
+ .append(MaxResponseLogSize).append(" bytes, so only ")
+ .append(MaxResponseLogSize).append(" characters are reserved for performance reasons.]")
+ .append("\r\n");
+ } else {
+ builder.append(line).append("\r\n");
+ }
+ totalLogByteSize += lineByteSize;
+ if (totalLogByteSize >= MaxResponseLogSize) {
+ break;
+ }
+ }
+ RollViewLogResponse rollViewLogRequestResponse =
+ new RollViewLogResponse(builder.toString());
+ channel.writeAndFlush(rollViewLogRequestResponse.convert2Command(message.getOpaque()));
+ }
+
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.ROLL_VIEW_LOG_REQUEST;
+ }
+}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/StateEventCallbackService.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/StateEventCallbackService.java
index 3ecd1d51e1..bd2fbcaf2c 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/StateEventCallbackService.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/StateEventCallbackService.java
@@ -21,7 +21,7 @@ import static org.apache.dolphinscheduler.common.constants.Constants.HTTP_CONNEC
import static org.apache.dolphinscheduler.common.constants.Constants.SLEEP_TIME_MILLIS;
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;
@@ -116,31 +116,31 @@ public class StateEventCallbackService {
* Send the command to target host, this method doesn't guarantee the command send success.
*
* @param host target host
- * @param command command need to send
+ * @param message command need to send
*/
- public void sendResult(Host host, Command command) {
- log.info("send result, host:{}, command:{}", host.getAddress(), command.toString());
+ public void sendResult(Host host, Message message) {
+ log.info("send result, host:{}, command:{}", host.getAddress(), message.toString());
newRemoteChannel(host).ifPresent(nettyRemoteChannel -> {
- nettyRemoteChannel.writeAndFlush(command);
+ nettyRemoteChannel.writeAndFlush(message);
});
}
/**
* send sync and return response command
* @param host
- * @param requestCommand
+ * @param requestMessage
* @return
* @throws RemotingException
* @throws InterruptedException
*/
- public Command sendSync(Host host, Command requestCommand) {
+ public Message sendSync(Host host, Message requestMessage) {
try {
- return this.nettyRemotingClient.sendSync(host, requestCommand, HTTP_CONNECTION_REQUEST_TIMEOUT);
+ return this.nettyRemotingClient.sendSync(host, requestMessage, HTTP_CONNECTION_REQUEST_TIMEOUT);
} catch (InterruptedException e) {
- log.error("send sync fail, host:{}, command:{}", host, requestCommand, e);
+ log.error("send sync fail, host:{}, command:{}", host, requestMessage, e);
Thread.currentThread().interrupt();
} catch (RemotingException e) {
- log.error("send sync fail, host:{}, command:{}", host, requestCommand, e);
+ log.error("send sync fail, host:{}, command:{}", host, requestMessage, e);
} finally {
this.nettyRemotingClient.closeChannel(host);
}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/ViewWholeLogProcessor.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/ViewWholeLogProcessor.java
new file mode 100644
index 0000000000..3de446690b
--- /dev/null
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/processor/ViewWholeLogProcessor.java
@@ -0,0 +1,50 @@
+/*
+ * 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.processor;
+
+import org.apache.dolphinscheduler.common.utils.JSONUtils;
+import org.apache.dolphinscheduler.remote.command.Message;
+import org.apache.dolphinscheduler.remote.command.MessageType;
+import org.apache.dolphinscheduler.remote.command.log.ViewLogRequest;
+import org.apache.dolphinscheduler.remote.command.log.ViewLogResponseResponse;
+
+import lombok.extern.slf4j.Slf4j;
+
+import org.springframework.stereotype.Component;
+
+import io.netty.channel.Channel;
+
+@Component
+@Slf4j
+public class ViewWholeLogProcessor extends BaseLogProcessor implements NettyRequestProcessor {
+
+ @Override
+ public void process(Channel channel, Message message) {
+ ViewLogRequest viewLogRequest = JSONUtils.parseObject(
+ message.getBody(), ViewLogRequest.class);
+ String viewLogPath = viewLogRequest.getPath();
+ String msg = readWholeFileContent(viewLogPath);
+ ViewLogResponseResponse viewLogResponse = new ViewLogResponseResponse(msg);
+ channel.writeAndFlush(viewLogResponse.convert2Command(message.getOpaque()));
+ }
+
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.VIEW_WHOLE_LOG_REQUEST;
+ }
+}
diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/utils/JsonSerializer.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/utils/JsonSerializer.java
index 193c8ae605..da3db257a6 100644
--- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/utils/JsonSerializer.java
+++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/utils/JsonSerializer.java
@@ -17,13 +17,26 @@
package org.apache.dolphinscheduler.remote.utils;
+import static com.fasterxml.jackson.databind.DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT;
+import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
+import static com.fasterxml.jackson.databind.DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL;
+import static com.fasterxml.jackson.databind.MapperFeature.REQUIRE_SETTERS_FOR_GETTERS;
+import static org.apache.dolphinscheduler.common.constants.DateConstants.YYYY_MM_DD_HH_MM_SS;
+
+import org.apache.dolphinscheduler.common.utils.JSONUtils;
+
import java.io.IOException;
import java.nio.charset.StandardCharsets;
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.util.TimeZone;
import lombok.extern.slf4j.Slf4j;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.json.JsonMapper;
+import com.fasterxml.jackson.databind.module.SimpleModule;
/**
* json serialize or deserialize
@@ -31,7 +44,18 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@Slf4j
public class JsonSerializer {
- private static final ObjectMapper objectMapper = new ObjectMapper();
+ private static final ObjectMapper objectMapper = JsonMapper.builder()
+ .configure(FAIL_ON_UNKNOWN_PROPERTIES, false)
+ .configure(ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, true)
+ .configure(READ_UNKNOWN_ENUM_VALUES_AS_NULL, true)
+ .configure(REQUIRE_SETTERS_FOR_GETTERS, true)
+ .addModule(new SimpleModule()
+ .addSerializer(LocalDateTime.class, new JSONUtils.LocalDateTimeSerializer())
+ .addDeserializer(LocalDateTime.class, new JSONUtils.LocalDateTimeDeserializer()))
+ .defaultTimeZone(TimeZone.getDefault())
+ .defaultDateFormat(new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS))
+ .build();
+
private JsonSerializer() {
}
diff --git a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/NettyRemotingClientTest.java b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/NettyRemotingClientTest.java
index ac8f9ac9aa..3c44e490b1 100644
--- a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/NettyRemotingClientTest.java
+++ b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/NettyRemotingClientTest.java
@@ -17,8 +17,8 @@
package org.apache.dolphinscheduler.remote;
-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.config.NettyClientConfig;
import org.apache.dolphinscheduler.remote.config.NettyServerConfig;
import org.apache.dolphinscheduler.remote.future.InvokeCallback;
@@ -50,11 +50,16 @@ public class NettyRemotingClientTest {
NettyServerConfig serverConfig = new NettyServerConfig();
NettyRemotingServer server = new NettyRemotingServer(serverConfig);
- server.registerProcessor(CommandType.PING, new NettyRequestProcessor() {
+ server.registerProcessor(new NettyRequestProcessor() {
@Override
- public void process(Channel channel, Command command) {
- channel.writeAndFlush(Pong.create(command.getOpaque()));
+ public void process(Channel channel, Message message) {
+ channel.writeAndFlush(Pong.create(message.getOpaque()));
+ }
+
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.PING;
}
});
@@ -62,10 +67,10 @@ public class NettyRemotingClientTest {
//
final NettyClientConfig clientConfig = new NettyClientConfig();
NettyRemotingClient client = new NettyRemotingClient(clientConfig);
- Command commandPing = Ping.create();
+ Message messagePing = Ping.create();
try {
- Command response = client.sendSync(new Host("127.0.0.1", serverConfig.getListenPort()), commandPing, 2000);
- Assertions.assertEquals(commandPing.getOpaque(), response.getOpaque());
+ Message response = client.sendSync(new Host("127.0.0.1", serverConfig.getListenPort()), messagePing, 2000);
+ Assertions.assertEquals(messagePing.getOpaque(), response.getOpaque());
} catch (Exception e) {
e.printStackTrace();
}
@@ -81,11 +86,16 @@ public class NettyRemotingClientTest {
NettyServerConfig serverConfig = new NettyServerConfig();
NettyRemotingServer server = new NettyRemotingServer(serverConfig);
- server.registerProcessor(CommandType.PING, new NettyRequestProcessor() {
+ server.registerProcessor(new NettyRequestProcessor() {
+
+ @Override
+ public void process(Channel channel, Message message) {
+ channel.writeAndFlush(Pong.create(message.getOpaque()));
+ }
@Override
- public void process(Channel channel, Command command) {
- channel.writeAndFlush(Pong.create(command.getOpaque()));
+ public MessageType getCommandType() {
+ return MessageType.PING;
}
});
server.start();
@@ -93,10 +103,10 @@ public class NettyRemotingClientTest {
final NettyClientConfig clientConfig = new NettyClientConfig();
NettyRemotingClient client = new NettyRemotingClient(clientConfig);
CountDownLatch latch = new CountDownLatch(1);
- Command commandPing = Ping.create();
+ Message messagePing = Ping.create();
try {
final AtomicLong opaque = new AtomicLong(0);
- client.sendAsync(new Host("127.0.0.1", serverConfig.getListenPort()), commandPing, 2000,
+ client.sendAsync(new Host("127.0.0.1", serverConfig.getListenPort()), messagePing, 2000,
new InvokeCallback() {
@Override
@@ -106,7 +116,7 @@ public class NettyRemotingClientTest {
}
});
latch.await();
- Assertions.assertEquals(commandPing.getOpaque(), opaque.get());
+ Assertions.assertEquals(messagePing.getOpaque(), opaque.get());
} catch (Exception e) {
e.printStackTrace();
}
@@ -130,8 +140,8 @@ public class NettyRemotingClientTest {
static {
ByteBuf ping = Unpooled.buffer();
- ping.writeByte(Command.MAGIC);
- ping.writeByte(CommandType.PING.ordinal());
+ ping.writeByte(Message.MAGIC);
+ ping.writeByte(MessageType.PING.ordinal());
ping.writeLong(0);
ping.writeInt(0);
ping.writeBytes(EMPTY_BODY);
@@ -152,11 +162,11 @@ public class NettyRemotingClientTest {
*
* @return command
*/
- public static Command create() {
- Command command = new Command();
- command.setType(CommandType.PING);
- command.setBody(EMPTY_BODY_ARRAY);
- return command;
+ public static Message create() {
+ Message message = new Message();
+ message.setType(MessageType.PING);
+ message.setBody(EMPTY_BODY_ARRAY);
+ return message;
}
}
@@ -179,8 +189,8 @@ public class NettyRemotingClientTest {
static {
ByteBuf ping = Unpooled.buffer();
- ping.writeByte(Command.MAGIC);
- ping.writeByte(CommandType.PONG.ordinal());
+ ping.writeByte(Message.MAGIC);
+ ping.writeByte(MessageType.PONG.ordinal());
ping.writeLong(0);
ping.writeInt(0);
ping.writeBytes(EMPTY_BODY);
@@ -202,11 +212,11 @@ public class NettyRemotingClientTest {
* @param opaque request unique identification
* @return command
*/
- public static Command create(long opaque) {
- Command command = new Command(opaque);
- command.setType(CommandType.PONG);
- command.setBody(EMPTY_BODY_ARRAY);
- return command;
+ public static Message create(long opaque) {
+ Message message = new Message(opaque);
+ message.setType(MessageType.PONG);
+ message.setBody(EMPTY_BODY_ARRAY);
+ return message;
}
}
}
diff --git a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendRequestCommandTest.java b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendRequestTest.java
similarity index 70%
rename from dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendRequestCommandTest.java
rename to dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendRequestTest.java
index e0c3e20e90..affc08028d 100644
--- a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendRequestCommandTest.java
+++ b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendRequestTest.java
@@ -18,24 +18,24 @@
package org.apache.dolphinscheduler.remote.command.alert;
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.Message;
+import org.apache.dolphinscheduler.remote.command.MessageType;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-public class AlertSendRequestCommandTest {
+public class AlertSendRequestTest {
@Test
public void testConvert2Command() {
int groupId = 1;
String title = "test-title";
String content = "test-content";
- AlertSendRequestCommand requestCommand =
- new AlertSendRequestCommand(groupId, title, content, WarningType.FAILURE.getCode());
- Command command = requestCommand.convert2Command();
- Assertions.assertEquals(CommandType.ALERT_SEND_REQUEST, command.getType());
- AlertSendRequestCommand verifyCommand = new AlertSendRequestCommand();
+ AlertSendRequest requestCommand =
+ new AlertSendRequest(groupId, title, content, WarningType.FAILURE.getCode());
+ Message message = requestCommand.convert2Command();
+ Assertions.assertEquals(MessageType.ALERT_SEND_REQUEST, message.getType());
+ AlertSendRequest verifyCommand = new AlertSendRequest();
verifyCommand.setGroupId(groupId);
verifyCommand.setContent(content);
verifyCommand.setTitle(title);
diff --git a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseCommandTest.java b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseTest.java
similarity index 59%
rename from dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseCommandTest.java
rename to dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseTest.java
index aceefb7980..41cdfbf957 100644
--- a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseCommandTest.java
+++ b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseTest.java
@@ -17,8 +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.command.Message;
+import org.apache.dolphinscheduler.remote.command.MessageType;
import java.util.ArrayList;
import java.util.List;
@@ -26,23 +26,24 @@ import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-public class AlertSendResponseCommandTest {
+public class AlertSendResponseTest {
@Test
public void testConvert2Command() {
- AlertSendResponseCommand alertSendResponseCommand = new AlertSendResponseCommand();
- alertSendResponseCommand.setSuccess(false);
- List<AlertSendResponseResult> responseResults = new ArrayList<>();
- AlertSendResponseResult responseResult1 = new AlertSendResponseResult();
+ AlertSendResponse alertSendResponse = new AlertSendResponse();
+ alertSendResponse.setSuccess(false);
+ List<AlertSendResponse.AlertSendResponseResult> responseResults = new ArrayList<>();
+ AlertSendResponse.AlertSendResponseResult responseResult1 = new AlertSendResponse.AlertSendResponseResult();
responseResult1.setSuccess(false);
responseResult1.setMessage("fail");
responseResults.add(responseResult1);
- AlertSendResponseResult responseResult2 = new AlertSendResponseResult(true, "success");
+ AlertSendResponse.AlertSendResponseResult responseResult2 =
+ new AlertSendResponse.AlertSendResponseResult(true, "success");
responseResults.add(responseResult2);
- alertSendResponseCommand.setResResults(responseResults);
+ alertSendResponse.setResResults(responseResults);
- Command command = alertSendResponseCommand.convert2Command(1);
- Assertions.assertEquals(CommandType.ALERT_SEND_RESPONSE, command.getType());
+ Message message = alertSendResponse.convert2Command(1);
+ Assertions.assertEquals(MessageType.ALERT_SEND_RESPONSE, message.getType());
}
}
diff --git a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/cache/CacheExpireCommandTest.java b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/cache/CacheExpireRequestTest.java
similarity index 69%
rename from dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/cache/CacheExpireCommandTest.java
rename to dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/cache/CacheExpireRequestTest.java
index bcc6108422..a9f032b6c1 100644
--- a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/cache/CacheExpireCommandTest.java
+++ b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/cache/CacheExpireRequestTest.java
@@ -18,19 +18,18 @@
package org.apache.dolphinscheduler.remote.command.cache;
import org.apache.dolphinscheduler.common.enums.CacheType;
-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.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-public class CacheExpireCommandTest {
+public class CacheExpireRequestTest {
@Test
public void testConvert2Command() {
- CacheExpireCommand cacheExpireCommand = new CacheExpireCommand(CacheType.TENANT, "1");
- Command command = cacheExpireCommand.convert2Command();
- Assertions.assertEquals(CommandType.CACHE_EXPIRE, command.getType());
+ CacheExpireRequest cacheExpireRequest = new CacheExpireRequest(CacheType.TENANT, "1");
+ Message message = cacheExpireRequest.convert2Command();
+ Assertions.assertEquals(MessageType.CACHE_EXPIRE, message.getType());
}
}
diff --git a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesRequestCommandTest.java b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesRequestTest.java
similarity index 69%
rename from dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesRequestCommandTest.java
rename to dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesRequestTest.java
index dd9027f68d..b66066200f 100644
--- a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesRequestCommandTest.java
+++ b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesRequestTest.java
@@ -17,18 +17,18 @@
package org.apache.dolphinscheduler.remote.command.log;
-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.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-public class GetLogBytesRequestCommandTest {
+public class GetLogBytesRequestTest {
@Test
public void testConvert2Command() {
- GetLogBytesRequestCommand getLogBytesRequestCommand = new GetLogBytesRequestCommand("/opt/test");
- Command command = getLogBytesRequestCommand.convert2Command();
- Assertions.assertEquals(CommandType.GET_LOG_BYTES_REQUEST, command.getType());
+ GetLogBytesRequest getLogBytesRequest = new GetLogBytesRequest("/opt/test");
+ Message message = getLogBytesRequest.convert2Command();
+ Assertions.assertEquals(MessageType.GET_LOG_BYTES_REQUEST, message.getType());
}
}
diff --git a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponseCommandTest.java b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponseTest.java
similarity index 75%
copy from dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponseCommandTest.java
copy to dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponseTest.java
index a6968174fb..3c0e17362c 100644
--- a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponseCommandTest.java
+++ b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponseTest.java
@@ -17,19 +17,19 @@
package org.apache.dolphinscheduler.remote.command.log;
-import org.apache.dolphinscheduler.remote.command.Command;
+import org.apache.dolphinscheduler.remote.command.Message;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-public class GetLogBytesResponseCommandTest {
+public class GetLogBytesResponseTest {
private byte[] data;
@Test
public void testConvert2Command() {
- GetLogBytesResponseCommand getLogBytesResponseCommand = new GetLogBytesResponseCommand(data);
- Command command = getLogBytesResponseCommand.convert2Command(122);
- Assertions.assertNotNull(command);
+ GetLogBytesResponse getLogBytesResponse = new GetLogBytesResponse(data);
+ Message message = getLogBytesResponse.convert2Command(122);
+ Assertions.assertNotNull(message);
}
}
diff --git a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogRequestCommandTest.java b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogRequestTest.java
similarity index 72%
rename from dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogRequestCommandTest.java
rename to dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogRequestTest.java
index 802589ccdf..6cb18ebf05 100644
--- a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogRequestCommandTest.java
+++ b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogRequestTest.java
@@ -17,18 +17,18 @@
package org.apache.dolphinscheduler.remote.command.log;
-import org.apache.dolphinscheduler.remote.command.Command;
+import org.apache.dolphinscheduler.remote.command.Message;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-public class RemoveTaskLogRequestCommandTest {
+public class RemoveTaskLogRequestTest {
@Test
public void testConvert2Command() {
- RemoveTaskLogResponseCommand removeTaskLogResponseCommand = new RemoveTaskLogResponseCommand();
- removeTaskLogResponseCommand.setStatus(true);
- Command command = removeTaskLogResponseCommand.convert2Command(122);
- Assertions.assertNotNull(command);
+ RemoveTaskLogResponse removeTaskLogResponse = new RemoveTaskLogResponse();
+ removeTaskLogResponse.setStatus(true);
+ Message message = removeTaskLogResponse.convert2Command(122);
+ Assertions.assertNotNull(message);
}
}
diff --git a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogResponseCommandTest.java b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogResponseTest.java
similarity index 72%
rename from dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogResponseCommandTest.java
rename to dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogResponseTest.java
index 574b795d05..b9b16b0368 100644
--- a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogResponseCommandTest.java
+++ b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogResponseTest.java
@@ -17,18 +17,18 @@
package org.apache.dolphinscheduler.remote.command.log;
-import org.apache.dolphinscheduler.remote.command.Command;
+import org.apache.dolphinscheduler.remote.command.Message;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-public class RemoveTaskLogResponseCommandTest {
+public class RemoveTaskLogResponseTest {
@Test
public void testConvert2Command() {
- RemoveTaskLogRequestCommand removeTaskLogRequestCommand = new RemoveTaskLogRequestCommand();
- removeTaskLogRequestCommand.setPath("/opt/zhangsan");
- Command command = removeTaskLogRequestCommand.convert2Command();
- Assertions.assertNotNull(command);
+ RemoveTaskLogRequest removeTaskLogRequest = new RemoveTaskLogRequest();
+ removeTaskLogRequest.setPath("/opt/zhangsan");
+ Message message = removeTaskLogRequest.convert2Command();
+ Assertions.assertNotNull(message);
}
}
diff --git a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogRequestCommandTest.java b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogRequestCommandTest.java
deleted file mode 100644
index cfda036105..0000000000
--- a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogRequestCommandTest.java
+++ /dev/null
@@ -1,36 +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.remote.command.Command;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class RollViewLogRequestCommandTest {
-
- @Test
- public void testConvert2Command() {
- RollViewLogRequestCommand rollViewLogRequestCommand = new RollViewLogRequestCommand();
- rollViewLogRequestCommand.setPath("/opt/test");
- rollViewLogRequestCommand.setSkipLineNum(1);
- rollViewLogRequestCommand.setLimit(1);
- Command command = rollViewLogRequestCommand.convert2Command();
- Assertions.assertNotNull(command);
- }
-}
diff --git a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponseCommandTest.java b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogRequestTest.java
similarity index 70%
rename from dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponseCommandTest.java
rename to dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogRequestTest.java
index a6968174fb..10e230bac4 100644
--- a/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponseCommandTest.java
+++ b/dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogRequestTest.java
@@ -17,19 +17,20 @@
package org.apache.dolphinscheduler.remote.command.log;
-import org.apache.dolphinscheduler.remote.command.Command;
+import org.apache.dolphinscheduler.remote.command.Message;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-public class GetLogBytesResponseCommandTest {
-
- private byte[] data;
+public class RollViewLogRequestTest {
@Test
public void testConvert2Command() {
- GetLogBytesResponseCommand getLogBytesResponseCommand = new GetLogBytesResponseCommand(data);
- Command command = getLogBytesResponseCommand.convert2Command(122);
- Assertions.assertNotNull(command);
+ RollViewLogRequest rollViewLogRequest = new RollViewLogRequest();
+ rollViewLogRequest.setPath("/opt/test");
+ rollViewLogRequest.setSkipLineNum(1);
+ rollViewLogRequest.setLimit(1);
+ Message message = rollViewLogRequest.convert2Command();
+ Assertions.assertNotNull(message);
}
}
diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/alert/AlertClientService.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/alert/AlertClientService.java
index 8bfb3dd3c3..34687ec6eb 100644
--- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/alert/AlertClientService.java
+++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/alert/AlertClientService.java
@@ -18,9 +18,9 @@
package org.apache.dolphinscheduler.service.alert;
import org.apache.dolphinscheduler.remote.NettyRemotingClient;
-import org.apache.dolphinscheduler.remote.command.Command;
-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.alert.AlertSendRequest;
+import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponse;
import org.apache.dolphinscheduler.remote.factory.NettyRemotingClientFactory;
import org.apache.dolphinscheduler.remote.utils.Host;
import org.apache.dolphinscheduler.remote.utils.JsonSerializer;
@@ -53,15 +53,6 @@ public class AlertClientService implements AutoCloseable {
this.isRunning = new AtomicBoolean(true);
}
- /**
- * alert client
- */
- public AlertClientService(String host, int port) {
- this();
- this.host = host;
- this.port = port;
- }
-
/**
* close
*/
@@ -84,7 +75,7 @@ public class AlertClientService implements AutoCloseable {
* @param content
* @return
*/
- public AlertSendResponseCommand sendAlert(int groupId, String title, String content, int strategy) {
+ public AlertSendResponse sendAlert(int groupId, String title, String content, int strategy) {
return this.sendAlert(this.host, this.port, groupId, title, content, strategy);
}
@@ -97,17 +88,17 @@ public class AlertClientService implements AutoCloseable {
* @param content content
* @return AlertSendResponseCommand
*/
- public AlertSendResponseCommand sendAlert(String host, int port, int groupId, String title, String content,
- int strategy) {
+ public AlertSendResponse sendAlert(String host, int port, int groupId, String title, String content,
+ int strategy) {
log.info("sync alert send, host : {}, port : {}, groupId : {}, title : {} , strategy : {} ", host, port,
groupId, title, strategy);
- AlertSendRequestCommand request = new AlertSendRequestCommand(groupId, title, content, strategy);
+ AlertSendRequest request = new AlertSendRequest(groupId, title, content, strategy);
final Host address = new Host(host, port);
try {
- Command command = request.convert2Command();
- Command response = this.client.sendSync(address, command, ALERT_REQUEST_TIMEOUT);
+ Message message = request.convert2Command();
+ Message response = this.client.sendSync(address, message, ALERT_REQUEST_TIMEOUT);
if (response != null) {
- return JsonSerializer.deserialize(response.getBody(), AlertSendResponseCommand.class);
+ return JsonSerializer.deserialize(response.getBody(), AlertSendResponse.class);
}
} catch (Exception e) {
log.error("sync alert send error", e);
diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/cache/CacheNotifyService.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/cache/CacheNotifyService.java
index 945efd574b..3d65c308e1 100644
--- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/cache/CacheNotifyService.java
+++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/cache/CacheNotifyService.java
@@ -17,9 +17,9 @@
package org.apache.dolphinscheduler.service.cache;
-import org.apache.dolphinscheduler.remote.command.Command;
+import org.apache.dolphinscheduler.remote.command.Message;
public interface CacheNotifyService {
- void notifyMaster(Command command);
+ void notifyMaster(Message message);
}
diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/cache/impl/CacheNotifyServiceImpl.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/cache/impl/CacheNotifyServiceImpl.java
index b6f3e4ec96..94e4054b26 100644
--- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/cache/impl/CacheNotifyServiceImpl.java
+++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/cache/impl/CacheNotifyServiceImpl.java
@@ -21,7 +21,7 @@ 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.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.processor.NettyRemoteChannel;
import org.apache.dolphinscheduler.remote.utils.Host;
@@ -108,11 +108,11 @@ public class CacheNotifyServiceImpl implements CacheNotifyService {
/**
* send result to master
*
- * @param command command
+ * @param message command
*/
@Override
- public void notifyMaster(Command command) {
- log.info("send result, command:{}", command.toString());
+ public void notifyMaster(Message message) {
+ log.info("send result, command:{}", message.toString());
try {
List<Server> serverList = registryClient.getServerList(NodeType.MASTER);
if (CollectionUtils.isEmpty(serverList)) {
@@ -125,7 +125,7 @@ public class CacheNotifyServiceImpl implements CacheNotifyService {
if (nettyRemoteChannel == null) {
continue;
}
- nettyRemoteChannel.writeAndFlush(command);
+ nettyRemoteChannel.writeAndFlush(message);
}
} catch (Exception e) {
log.error("notify master error", e);
diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/log/LogClient.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/log/LogClient.java
index 1c279ce026..ddf4f6fd56 100644
--- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/log/LogClient.java
+++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/log/LogClient.java
@@ -25,17 +25,17 @@ import org.apache.dolphinscheduler.common.utils.NetUtils;
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
import org.apache.dolphinscheduler.remote.NettyRemotingClient;
-import org.apache.dolphinscheduler.remote.command.Command;
-import org.apache.dolphinscheduler.remote.command.log.GetAppIdRequestCommand;
-import org.apache.dolphinscheduler.remote.command.log.GetAppIdResponseCommand;
-import org.apache.dolphinscheduler.remote.command.log.GetLogBytesRequestCommand;
-import org.apache.dolphinscheduler.remote.command.log.GetLogBytesResponseCommand;
-import org.apache.dolphinscheduler.remote.command.log.RemoveTaskLogRequestCommand;
-import org.apache.dolphinscheduler.remote.command.log.RemoveTaskLogResponseCommand;
-import org.apache.dolphinscheduler.remote.command.log.RollViewLogRequestCommand;
-import org.apache.dolphinscheduler.remote.command.log.RollViewLogResponseCommand;
-import org.apache.dolphinscheduler.remote.command.log.ViewLogRequestCommand;
-import org.apache.dolphinscheduler.remote.command.log.ViewLogResponseCommand;
+import org.apache.dolphinscheduler.remote.command.Message;
+import org.apache.dolphinscheduler.remote.command.log.GetAppIdRequest;
+import org.apache.dolphinscheduler.remote.command.log.GetAppIdResponse;
+import org.apache.dolphinscheduler.remote.command.log.GetLogBytesRequest;
+import org.apache.dolphinscheduler.remote.command.log.GetLogBytesResponse;
+import org.apache.dolphinscheduler.remote.command.log.RemoveTaskLogRequest;
+import org.apache.dolphinscheduler.remote.command.log.RemoveTaskLogResponse;
+import org.apache.dolphinscheduler.remote.command.log.RollViewLogRequest;
+import org.apache.dolphinscheduler.remote.command.log.RollViewLogResponse;
+import org.apache.dolphinscheduler.remote.command.log.ViewLogRequest;
+import org.apache.dolphinscheduler.remote.command.log.ViewLogResponseResponse;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
import org.apache.dolphinscheduler.remote.factory.NettyRemotingClientFactory;
import org.apache.dolphinscheduler.remote.utils.Host;
@@ -76,14 +76,14 @@ public class LogClient implements AutoCloseable {
public String rollViewLog(String host, int port, String path, int skipLineNum, int limit) {
log.info("Roll view log from host : {}, port : {}, path {}, skipLineNum {} ,limit {}", host, port, path,
skipLineNum, limit);
- RollViewLogRequestCommand request = new RollViewLogRequestCommand(path, skipLineNum, limit);
+ RollViewLogRequest request = new RollViewLogRequest(path, skipLineNum, limit);
final Host address = new Host(host, port);
try {
- Command command = request.convert2Command();
- Command response = client.sendSync(address, command, LOG_REQUEST_TIMEOUT);
+ Message message = request.convert2Command();
+ Message response = client.sendSync(address, message, LOG_REQUEST_TIMEOUT);
if (response != null) {
- RollViewLogResponseCommand rollReviewLog =
- JSONUtils.parseObject(response.getBody(), RollViewLogResponseCommand.class);
+ RollViewLogResponse rollReviewLog =
+ JSONUtils.parseObject(response.getBody(), RollViewLogResponse.class);
return rollReviewLog.getMsg();
}
return "Roll view log response is null";
@@ -110,17 +110,17 @@ public class LogClient implements AutoCloseable {
*/
public String viewLog(String host, int port, String path) {
log.info("View log from host: {}, port: {}, logPath: {}", host, port, path);
- ViewLogRequestCommand request = new ViewLogRequestCommand(path);
+ ViewLogRequest request = new ViewLogRequest(path);
final Host address = new Host(host, port);
try {
if (NetUtils.getHost().equals(host)) {
return LogUtils.readWholeFileContentFromLocal(request.getPath());
} else {
- Command command = request.convert2Command();
- Command response = this.client.sendSync(address, command, LOG_REQUEST_TIMEOUT);
+ Message message = request.convert2Command();
+ Message response = this.client.sendSync(address, message, LOG_REQUEST_TIMEOUT);
if (response != null) {
- ViewLogResponseCommand viewLog =
- JSONUtils.parseObject(response.getBody(), ViewLogResponseCommand.class);
+ ViewLogResponseResponse viewLog =
+ JSONUtils.parseObject(response.getBody(), ViewLogResponseResponse.class);
return viewLog.getMsg();
}
return "View log response is null";
@@ -146,14 +146,14 @@ public class LogClient implements AutoCloseable {
*/
public byte[] getLogBytes(String host, int port, String path) {
log.info("Get log bytes from host: {}, port: {}, logPath {}", host, port, path);
- GetLogBytesRequestCommand request = new GetLogBytesRequestCommand(path);
+ GetLogBytesRequest request = new GetLogBytesRequest(path);
final Host address = new Host(host, port);
try {
- Command command = request.convert2Command();
- Command response = this.client.sendSync(address, command, LOG_REQUEST_TIMEOUT);
+ Message message = request.convert2Command();
+ Message response = this.client.sendSync(address, message, LOG_REQUEST_TIMEOUT);
if (response != null) {
- GetLogBytesResponseCommand getLog =
- JSONUtils.parseObject(response.getBody(), GetLogBytesResponseCommand.class);
+ GetLogBytesResponse getLog =
+ JSONUtils.parseObject(response.getBody(), GetLogBytesResponse.class);
return getLog.getData() == null ? EMPTY_BYTE_ARRAY : getLog.getData();
}
return EMPTY_BYTE_ARRAY;
@@ -177,22 +177,22 @@ public class LogClient implements AutoCloseable {
*/
public void removeTaskLog(@NonNull Host host, String path) {
log.info("Begin remove task log from host: {} logPath {}", host, path);
- RemoveTaskLogRequestCommand request = new RemoveTaskLogRequestCommand(path);
+ RemoveTaskLogRequest request = new RemoveTaskLogRequest(path);
try {
- Command command = request.convert2Command();
- client.sendAsync(host, command, LOG_REQUEST_TIMEOUT, responseFuture -> {
+ Message message = request.convert2Command();
+ client.sendAsync(host, message, LOG_REQUEST_TIMEOUT, responseFuture -> {
if (responseFuture.getCause() != null) {
log.error("Remove task log from host: {} logPath {} error, meet an unknown exception", host,
path, responseFuture.getCause());
return;
}
- Command response = responseFuture.getResponseCommand();
+ Message response = responseFuture.getResponseCommand();
if (response == null) {
log.error("Remove task log from host: {} logPath {} error, response is null", host, path);
return;
}
- RemoveTaskLogResponseCommand removeTaskLogResponse =
- JSONUtils.parseObject(response.getBody(), RemoveTaskLogResponseCommand.class);
+ RemoveTaskLogResponse removeTaskLogResponse =
+ JSONUtils.parseObject(response.getBody(), RemoveTaskLogResponse.class);
if (removeTaskLogResponse.getStatus()) {
log.info("Success remove task log from host: {} logPath {}", host, path);
} else {
@@ -219,11 +219,11 @@ public class LogClient implements AutoCloseable {
appIds = LogUtils.getAppIds(taskLogFilePath, taskAppInfoPath,
PropertyUtils.getString(APPID_COLLECT, DEFAULT_COLLECT_WAY));
} else {
- final Command command = new GetAppIdRequestCommand(taskLogFilePath, taskAppInfoPath).convert2Command();
- Command response = this.client.sendSync(workerAddress, command, LOG_REQUEST_TIMEOUT);
+ final Message message = new GetAppIdRequest(taskLogFilePath, taskAppInfoPath).convert2Command();
+ Message response = this.client.sendSync(workerAddress, message, LOG_REQUEST_TIMEOUT);
if (response != null) {
- GetAppIdResponseCommand responseCommand =
- JSONUtils.parseObject(response.getBody(), GetAppIdResponseCommand.class);
+ GetAppIdResponse responseCommand =
+ JSONUtils.parseObject(response.getBody(), GetAppIdResponse.class);
appIds = responseCommand.getAppIds();
}
}
diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
index 48689909db..80bb6e3711 100644
--- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
+++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
@@ -231,9 +231,6 @@ public interface ProcessService {
TaskGroupQueue loadTaskGroupQueue(int taskId);
- void sendStartTask2Master(ProcessInstance processInstance, int taskId,
- org.apache.dolphinscheduler.remote.command.CommandType taskType);
-
ProcessInstance loadNextProcess4Serial(long code, int state, int id);
public String findConfigYamlByName(String clusterName);
diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
index 0c7b4a9b36..281c57e2fc 100644
--- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
+++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
@@ -125,8 +125,7 @@ import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters
import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode;
import org.apache.dolphinscheduler.plugin.task.api.parameters.SubProcessParameters;
import org.apache.dolphinscheduler.plugin.task.api.parameters.TaskTimeoutParameter;
-import org.apache.dolphinscheduler.remote.command.TaskEventChangeCommand;
-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.command.CommandService;
@@ -390,12 +389,12 @@ public class ProcessServiceImpl implements ProcessService {
int update = processInstanceDao.updateProcessInstance(info);
// determine whether the process is normal
if (update > 0) {
- WorkflowStateEventChangeCommand workflowStateEventChangeCommand =
- new WorkflowStateEventChangeCommand(
+ WorkflowStateEventChangeRequest workflowStateEventChangeRequest =
+ new WorkflowStateEventChangeRequest(
info.getId(), 0, info.getState(), info.getId(), 0);
try {
Host host = new Host(info.getHost());
- stateEventCallbackService.sendResult(host, workflowStateEventChangeCommand.convert2Command());
+ stateEventCallbackService.sendResult(host, workflowStateEventChangeRequest.convert2Command());
} catch (Exception e) {
log.error("sendResultError", e);
}
@@ -2584,16 +2583,6 @@ public class ProcessServiceImpl implements ProcessService {
return this.taskGroupQueueMapper.queryByTaskId(taskId);
}
- @Override
- public void sendStartTask2Master(ProcessInstance processInstance, int taskId,
- org.apache.dolphinscheduler.remote.command.CommandType taskType) {
- TaskEventChangeCommand taskEventChangeCommand = new TaskEventChangeCommand(
- processInstance.getId(), taskId);
- Host host = new Host(processInstance.getHost());
- stateEventCallbackService.sendResult(host, taskEventChangeCommand.convert2Command(taskType));
- log.info("Success send command to master: {}, command: {}", host, taskEventChangeCommand);
- }
-
@Override
public ProcessInstance loadNextProcess4Serial(long code, int state, int id) {
return this.processInstanceMapper.loadNextProcess4Serial(code, state, id);
diff --git a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/alert/AlertClientServiceTest.java b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/alert/AlertClientServiceTest.java
index dd065cb0b6..7bd1b26955 100644
--- a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/alert/AlertClientServiceTest.java
+++ b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/alert/AlertClientServiceTest.java
@@ -19,11 +19,11 @@ package org.apache.dolphinscheduler.service.alert;
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.remote.NettyRemotingClient;
-import org.apache.dolphinscheduler.remote.command.Command;
-import org.apache.dolphinscheduler.remote.command.alert.AlertSendRequestCommand;
-import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponseCommand;
-import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponseResult;
+import org.apache.dolphinscheduler.remote.command.Message;
+import org.apache.dolphinscheduler.remote.command.alert.AlertSendRequest;
+import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponse;
import org.apache.dolphinscheduler.remote.factory.NettyRemotingClientFactory;
+import org.apache.dolphinscheduler.remote.utils.Host;
import java.util.ArrayList;
import java.util.List;
@@ -74,32 +74,33 @@ public class AlertClientServiceTest {
String content = "test-content";
// 1.alter server does not exist
- AlertSendResponseCommand alertSendResponseCommand =
+ AlertSendResponse alertSendResponse =
alertClient.sendAlert(host, port, groupId, title, content, WarningType.FAILURE.getCode());
- Assertions.assertNull(alertSendResponseCommand);
+ Assertions.assertNull(alertSendResponse);
- AlertSendRequestCommand alertSendRequestCommand =
- new AlertSendRequestCommand(groupId, title, content, WarningType.FAILURE.getCode());
- Command reqCommand = alertSendRequestCommand.convert2Command();
+ AlertSendRequest alertSendRequest =
+ new AlertSendRequest(groupId, title, content, WarningType.FAILURE.getCode());
+ Message reqMessage = alertSendRequest.convert2Command();
boolean sendResponseStatus;
- List<AlertSendResponseResult> sendResponseResults = new ArrayList<>();
+ List<AlertSendResponse.AlertSendResponseResult> sendResponseResults = new ArrayList<>();
// 2.alter instance does not exist
sendResponseStatus = false;
- AlertSendResponseResult alertResult = new AlertSendResponseResult();
+ AlertSendResponse.AlertSendResponseResult alertResult = new AlertSendResponse.AlertSendResponseResult();
String message = String.format("Alert GroupId %s send error : not found alert instance", groupId);
alertResult.setSuccess(false);
alertResult.setMessage(message);
sendResponseResults.add(alertResult);
- AlertSendResponseCommand alertSendResponseCommandData =
- new AlertSendResponseCommand(sendResponseStatus, sendResponseResults);
- Command resCommand = alertSendResponseCommandData.convert2Command(reqCommand.getOpaque());
+ AlertSendResponse alertSendResponseData =
+ new AlertSendResponse(sendResponseStatus, sendResponseResults);
+ Message resMessage = alertSendResponseData.convert2Command(reqMessage.getOpaque());
- Mockito.when(client.sendSync(Mockito.any(), Mockito.any(), Mockito.anyLong())).thenReturn(resCommand);
- alertSendResponseCommand =
+ Mockito.when(client.sendSync(Mockito.any(Host.class), Mockito.any(Message.class), Mockito.anyLong()))
+ .thenReturn(resMessage);
+ alertSendResponse =
alertClient.sendAlert(host, port, groupId, title, content, WarningType.FAILURE.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.alter plugin does not exist
@@ -108,13 +109,13 @@ public class AlertClientServiceTest {
message = String.format("Alert Plugin %s send error : return value is null", pluginInstanceName);
alertResult.setSuccess(false);
alertResult.setMessage(message);
- alertSendResponseCommandData = new AlertSendResponseCommand(sendResponseStatus, sendResponseResults);
- resCommand = alertSendResponseCommandData.convert2Command(reqCommand.getOpaque());
- Mockito.when(client.sendSync(Mockito.any(), Mockito.any(), Mockito.anyLong())).thenReturn(resCommand);
- alertSendResponseCommand =
+ alertSendResponseData = new AlertSendResponse(sendResponseStatus, sendResponseResults);
+ resMessage = alertSendResponseData.convert2Command(reqMessage.getOpaque());
+ Mockito.when(client.sendSync(Mockito.any(), Mockito.any(), Mockito.anyLong())).thenReturn(resMessage);
+ alertSendResponse =
alertClient.sendAlert(host, port, groupId, title, content, WarningType.FAILURE.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.alter result is null
@@ -122,26 +123,26 @@ public class AlertClientServiceTest {
message = String.format("Alert Plugin %s send error : return result value is null", pluginInstanceName);
alertResult.setSuccess(false);
alertResult.setMessage(message);
- alertSendResponseCommandData = new AlertSendResponseCommand(sendResponseStatus, sendResponseResults);
- resCommand = alertSendResponseCommandData.convert2Command(reqCommand.getOpaque());
- Mockito.when(client.sendSync(Mockito.any(), Mockito.any(), Mockito.anyLong())).thenReturn(resCommand);
- alertSendResponseCommand =
+ alertSendResponseData = new AlertSendResponse(sendResponseStatus, sendResponseResults);
+ resMessage = alertSendResponseData.convert2Command(reqMessage.getOpaque());
+ Mockito.when(client.sendSync(Mockito.any(), Mockito.any(), Mockito.anyLong())).thenReturn(resMessage);
+ alertSendResponse =
alertClient.sendAlert(host, port, groupId, title, content, WarningType.FAILURE.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.abnormal information inside the alert plug-in code
sendResponseStatus = false;
alertResult.setSuccess(false);
alertResult.setMessage("Abnormal information inside the alert plug-in code");
- alertSendResponseCommandData = new AlertSendResponseCommand(sendResponseStatus, sendResponseResults);
- resCommand = alertSendResponseCommandData.convert2Command(reqCommand.getOpaque());
- Mockito.when(client.sendSync(Mockito.any(), Mockito.any(), Mockito.anyLong())).thenReturn(resCommand);
- alertSendResponseCommand =
+ alertSendResponseData = new AlertSendResponse(sendResponseStatus, sendResponseResults);
+ resMessage = alertSendResponseData.convert2Command(reqMessage.getOpaque());
+ Mockito.when(client.sendSync(Mockito.any(), Mockito.any(), Mockito.anyLong())).thenReturn(resMessage);
+ alertSendResponse =
alertClient.sendAlert(host, port, groupId, title, content, WarningType.FAILURE.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()));
// 6.alert plugin send success
@@ -149,13 +150,13 @@ public class AlertClientServiceTest {
message = String.format("Alert Plugin %s send success", pluginInstanceName);
alertResult.setSuccess(true);
alertResult.setMessage(message);
- alertSendResponseCommandData = new AlertSendResponseCommand(sendResponseStatus, sendResponseResults);
- resCommand = alertSendResponseCommandData.convert2Command(reqCommand.getOpaque());
- Mockito.when(client.sendSync(Mockito.any(), Mockito.any(), Mockito.anyLong())).thenReturn(resCommand);
- alertSendResponseCommand =
+ alertSendResponseData = new AlertSendResponse(sendResponseStatus, sendResponseResults);
+ resMessage = alertSendResponseData.convert2Command(reqMessage.getOpaque());
+ Mockito.when(client.sendSync(Mockito.any(), Mockito.any(), Mockito.anyLong())).thenReturn(resMessage);
+ alertSendResponse =
alertClient.sendAlert(host, port, groupId, title, content, WarningType.FAILURE.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()));
if (Objects.nonNull(alertClient) && alertClient.isRunning()) {
diff --git a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/cache/CacheNotifyServiceTest.java b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/cache/CacheNotifyServiceTest.java
index e59b7e55c9..bf1dc575f8 100644
--- a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/cache/CacheNotifyServiceTest.java
+++ b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/cache/CacheNotifyServiceTest.java
@@ -23,10 +23,11 @@ import org.apache.dolphinscheduler.common.model.Server;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.registry.api.RegistryClient;
import org.apache.dolphinscheduler.remote.NettyRemotingServer;
-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.config.NettyServerConfig;
+import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.service.cache.impl.CacheNotifyServiceImpl;
import java.util.ArrayList;
@@ -40,6 +41,8 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
+import io.netty.channel.Channel;
+
/**
* tenant cache proxy test
*/
@@ -56,13 +59,22 @@ public class CacheNotifyServiceTest {
public void testNotifyMaster() {
User user1 = new User();
user1.setId(100);
- Command cacheExpireCommand = new CacheExpireCommand(CacheType.USER, "100").convert2Command();
+ Message cacheExpireMessage = new CacheExpireRequest(CacheType.USER, "100").convert2Command();
NettyServerConfig serverConfig = new NettyServerConfig();
NettyRemotingServer nettyRemotingServer = new NettyRemotingServer(serverConfig);
- nettyRemotingServer.registerProcessor(CommandType.CACHE_EXPIRE, (channel, command) -> {
- Assertions.assertEquals(cacheExpireCommand, command);
+ nettyRemotingServer.registerProcessor(new NettyRequestProcessor() {
+
+ @Override
+ public void process(Channel channel, Message message) {
+ Assertions.assertEquals(cacheExpireMessage, message);
+ }
+
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.CACHE_EXPIRE;
+ }
});
nettyRemotingServer.start();
@@ -74,7 +86,7 @@ public class CacheNotifyServiceTest {
Mockito.when(registryClient.getServerList(NodeType.MASTER)).thenReturn(serverList);
- cacheNotifyService.notifyMaster(cacheExpireCommand);
+ cacheNotifyService.notifyMaster(cacheExpireMessage);
nettyRemotingServer.close();
}
diff --git a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/command/CommandServiceImplTest.java b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/command/MessageServiceImplTest.java
similarity index 99%
rename from dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/command/CommandServiceImplTest.java
rename to dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/command/MessageServiceImplTest.java
index 1139bcf1da..0cde76bdfe 100644
--- a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/command/CommandServiceImplTest.java
+++ b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/command/MessageServiceImplTest.java
@@ -56,7 +56,7 @@ import com.fasterxml.jackson.databind.JsonNode;
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
-class CommandServiceImplTest {
+class MessageServiceImplTest {
@InjectMocks
private CommandServiceImpl commandService;
diff --git a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/log/LoggerRequestProcessorTest.java b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/log/LoggerRequestProcessorTest.java
index 31912e2c6a..4501f0ca02 100644
--- a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/log/LoggerRequestProcessorTest.java
+++ b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/log/LoggerRequestProcessorTest.java
@@ -19,10 +19,10 @@ package org.apache.dolphinscheduler.service.log;
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.log.ViewLogRequestCommand;
-import org.apache.dolphinscheduler.remote.processor.LoggerRequestProcessor;
+import org.apache.dolphinscheduler.remote.command.Message;
+import org.apache.dolphinscheduler.remote.command.MessageType;
+import org.apache.dolphinscheduler.remote.command.log.ViewLogRequest;
+import org.apache.dolphinscheduler.remote.processor.ViewWholeLogProcessor;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@@ -53,17 +53,17 @@ public class LoggerRequestProcessorTest {
public void testProcessViewWholeLogRequest() {
System.setProperty("DOLPHINSCHEDULER_WORKER_HOME", System.getProperty("user.dir"));
Channel channel = Mockito.mock(Channel.class);
- Mockito.when(channel.writeAndFlush(Mockito.any(Command.class))).thenReturn(null);
+ Mockito.when(channel.writeAndFlush(Mockito.any(Message.class))).thenReturn(null);
Mockito.when(LogUtils.readWholeFileContentFromLocal(Mockito.anyString())).thenReturn("");
String userDir = System.getProperty("user.dir");
- ViewLogRequestCommand logRequestCommand = new ViewLogRequestCommand(userDir + "/log/path/a.log");
+ ViewLogRequest logRequestCommand = new ViewLogRequest(userDir + "/log/path/a.log");
- Command command = new Command();
- command.setType(CommandType.VIEW_WHOLE_LOG_REQUEST);
- command.setBody(JSONUtils.toJsonByteArray(logRequestCommand));
+ Message message = new Message();
+ message.setType(MessageType.VIEW_WHOLE_LOG_REQUEST);
+ message.setBody(JSONUtils.toJsonByteArray(logRequestCommand));
- LoggerRequestProcessor loggerRequestProcessor = new LoggerRequestProcessor();
- loggerRequestProcessor.process(channel, command);
+ ViewWholeLogProcessor loggerRequestProcessor = new ViewWholeLogProcessor();
+ loggerRequestProcessor.process(channel, message);
}
@Test
@@ -72,14 +72,14 @@ public class LoggerRequestProcessorTest {
Channel channel = Mockito.mock(Channel.class);
Mockito.when(LogUtils.readWholeFileContentFromLocal(Mockito.anyString())).thenReturn("");
String userDir = System.getProperty("user.dir");
- ViewLogRequestCommand logRequestCommand = new ViewLogRequestCommand(userDir + "/log/path/a");
+ ViewLogRequest logRequestCommand = new ViewLogRequest(userDir + "/log/path/a");
- Command command = new Command();
- command.setType(CommandType.VIEW_WHOLE_LOG_REQUEST);
- command.setBody(JSONUtils.toJsonByteArray(logRequestCommand));
+ Message message = new Message();
+ message.setType(MessageType.VIEW_WHOLE_LOG_REQUEST);
+ message.setBody(JSONUtils.toJsonByteArray(logRequestCommand));
- LoggerRequestProcessor loggerRequestProcessor = new LoggerRequestProcessor();
- loggerRequestProcessor.process(channel, command);
+ ViewWholeLogProcessor loggerRequestProcessor = new ViewWholeLogProcessor();
+ loggerRequestProcessor.process(channel, message);
}
@Test
@@ -88,14 +88,14 @@ public class LoggerRequestProcessorTest {
Channel channel = Mockito.mock(Channel.class);
Mockito.when(LogUtils.readWholeFileContentFromLocal(Mockito.anyString())).thenReturn("");
String userDir = System.getProperty("user.dir");
- ViewLogRequestCommand logRequestCommand = new ViewLogRequestCommand(userDir + "/log/../../a.log");
+ ViewLogRequest logRequestCommand = new ViewLogRequest(userDir + "/log/../../a.log");
- Command command = new Command();
- command.setType(CommandType.VIEW_WHOLE_LOG_REQUEST);
- command.setBody(JSONUtils.toJsonByteArray(logRequestCommand));
+ Message message = new Message();
+ message.setType(MessageType.VIEW_WHOLE_LOG_REQUEST);
+ message.setBody(JSONUtils.toJsonByteArray(logRequestCommand));
- LoggerRequestProcessor loggerRequestProcessor = new LoggerRequestProcessor();
- loggerRequestProcessor.process(channel, command);
+ ViewWholeLogProcessor loggerRequestProcessor = new ViewWholeLogProcessor();
+ loggerRequestProcessor.process(channel, message);
}
@Test
@@ -103,13 +103,13 @@ public class LoggerRequestProcessorTest {
System.setProperty("DOLPHINSCHEDULER_WORKER_HOME", System.getProperty("user.dir"));
Channel channel = Mockito.mock(Channel.class);
Mockito.when(LogUtils.readWholeFileContentFromLocal(Mockito.anyString())).thenReturn("");
- ViewLogRequestCommand logRequestCommand = new ViewLogRequestCommand("/log/a.log");
+ ViewLogRequest logRequestCommand = new ViewLogRequest("/log/a.log");
- Command command = new Command();
- command.setType(CommandType.VIEW_WHOLE_LOG_REQUEST);
- command.setBody(JSONUtils.toJsonByteArray(logRequestCommand));
+ Message message = new Message();
+ message.setType(MessageType.VIEW_WHOLE_LOG_REQUEST);
+ message.setBody(JSONUtils.toJsonByteArray(logRequestCommand));
- LoggerRequestProcessor loggerRequestProcessor = new LoggerRequestProcessor();
- loggerRequestProcessor.process(channel, command);
+ ViewWholeLogProcessor loggerRequestProcessor = new ViewWholeLogProcessor();
+ loggerRequestProcessor.process(channel, message);
}
}
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/MessageRetryRunner.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/MessageRetryRunner.java
index f75767ef27..830f470a44 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/MessageRetryRunner.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/MessageRetryRunner.java
@@ -21,8 +21,8 @@ import org.apache.dolphinscheduler.common.constants.Constants;
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.BaseCommand;
-import org.apache.dolphinscheduler.remote.command.CommandType;
+import org.apache.dolphinscheduler.remote.command.BaseMessage;
+import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.commons.collections4.MapUtils;
@@ -54,9 +54,9 @@ public class MessageRetryRunner extends BaseDaemonThread {
@Autowired
private List<MessageSender> messageSenders;
- private Map<CommandType, MessageSender<BaseCommand>> messageSenderMap = new HashMap<>();
+ private Map<MessageType, MessageSender<BaseMessage>> messageSenderMap = new HashMap<>();
- private Map<Integer, Map<CommandType, BaseCommand>> needToRetryMessages = new ConcurrentHashMap<>();
+ private Map<Integer, Map<MessageType, BaseMessage>> needToRetryMessages = new ConcurrentHashMap<>();
@Override
public synchronized void start() {
@@ -69,13 +69,13 @@ public class MessageRetryRunner extends BaseDaemonThread {
log.info("Message retry runner started");
}
- public void addRetryMessage(int taskInstanceId, @NonNull CommandType messageType, BaseCommand baseCommand) {
+ public void addRetryMessage(int taskInstanceId, @NonNull MessageType messageType, BaseMessage baseMessage) {
needToRetryMessages.computeIfAbsent(taskInstanceId, k -> new ConcurrentHashMap<>()).put(messageType,
- baseCommand);
+ baseMessage);
}
- public void removeRetryMessage(int taskInstanceId, @NonNull CommandType messageType) {
- Map<CommandType, BaseCommand> retryMessages = needToRetryMessages.get(taskInstanceId);
+ public void removeRetryMessage(int taskInstanceId, @NonNull MessageType messageType) {
+ Map<MessageType, BaseMessage> retryMessages = needToRetryMessages.get(taskInstanceId);
if (retryMessages != null) {
retryMessages.remove(messageType);
}
@@ -86,7 +86,7 @@ public class MessageRetryRunner extends BaseDaemonThread {
}
public void updateMessageHost(int taskInstanceId, String messageReceiverHost) {
- Map<CommandType, BaseCommand> needToRetryMessages = this.needToRetryMessages.get(taskInstanceId);
+ Map<MessageType, BaseMessage> needToRetryMessages = this.needToRetryMessages.get(taskInstanceId);
if (needToRetryMessages != null) {
needToRetryMessages.values().forEach(baseMessage -> {
baseMessage.setMessageReceiverAddress(messageReceiverHost);
@@ -102,21 +102,21 @@ public class MessageRetryRunner extends BaseDaemonThread {
}
long now = System.currentTimeMillis();
- Iterator<Map.Entry<Integer, Map<CommandType, BaseCommand>>> iterator =
+ Iterator<Map.Entry<Integer, Map<MessageType, BaseMessage>>> iterator =
needToRetryMessages.entrySet().iterator();
while (iterator.hasNext()) {
- Map.Entry<Integer, Map<CommandType, BaseCommand>> taskEntry = iterator.next();
+ Map.Entry<Integer, Map<MessageType, BaseMessage>> taskEntry = iterator.next();
Integer taskInstanceId = taskEntry.getKey();
- Map<CommandType, BaseCommand> retryMessageMap = taskEntry.getValue();
+ Map<MessageType, BaseMessage> retryMessageMap = taskEntry.getValue();
if (retryMessageMap.isEmpty()) {
iterator.remove();
continue;
}
LogUtils.setTaskInstanceIdMDC(taskInstanceId);
try {
- for (Map.Entry<CommandType, BaseCommand> messageEntry : retryMessageMap.entrySet()) {
- CommandType messageType = messageEntry.getKey();
- BaseCommand message = messageEntry.getValue();
+ for (Map.Entry<MessageType, BaseMessage> messageEntry : retryMessageMap.entrySet()) {
+ MessageType messageType = messageEntry.getKey();
+ BaseMessage message = messageEntry.getValue();
if (now - message.getMessageSendTime() > MESSAGE_RETRY_WINDOW) {
log.info("Begin retry send message to master, message: {}", message);
message.setMessageSendTime(now);
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/MessageSender.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/MessageSender.java
index fc9a9ee81f..79bc7eec6c 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/MessageSender.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/MessageSender.java
@@ -18,11 +18,11 @@
package org.apache.dolphinscheduler.server.worker.message;
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
-import org.apache.dolphinscheduler.remote.command.BaseCommand;
-import org.apache.dolphinscheduler.remote.command.CommandType;
+import org.apache.dolphinscheduler.remote.command.BaseMessage;
+import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
-public interface MessageSender<T extends BaseCommand> {
+public interface MessageSender<T extends BaseMessage> {
/**
* Send the message
@@ -39,5 +39,5 @@ public interface MessageSender<T extends BaseCommand> {
/**
* The message type can be sent by this sender.
*/
- CommandType getMessageType();
+ MessageType getMessageType();
}
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/TaskExecuteResultMessageSender.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/TaskExecuteResultMessageSender.java
index dd410e7c60..2aed7b69cc 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/TaskExecuteResultMessageSender.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/TaskExecuteResultMessageSender.java
@@ -18,8 +18,8 @@
package org.apache.dolphinscheduler.server.worker.message;
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
-import org.apache.dolphinscheduler.remote.command.CommandType;
-import org.apache.dolphinscheduler.remote.command.TaskExecuteResultCommand;
+import org.apache.dolphinscheduler.remote.command.MessageType;
+import org.apache.dolphinscheduler.remote.command.task.TaskExecuteResultMessage;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
import org.apache.dolphinscheduler.remote.utils.Host;
import org.apache.dolphinscheduler.server.worker.config.WorkerConfig;
@@ -29,7 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
-public class TaskExecuteResultMessageSender implements MessageSender<TaskExecuteResultCommand> {
+public class TaskExecuteResultMessageSender implements MessageSender<TaskExecuteResultMessage> {
@Autowired
private WorkerConfig workerConfig;
@@ -38,14 +38,14 @@ public class TaskExecuteResultMessageSender implements MessageSender<TaskExecute
private WorkerRpcClient workerRpcClient;
@Override
- public void sendMessage(TaskExecuteResultCommand message) throws RemotingException {
+ public void sendMessage(TaskExecuteResultMessage message) throws RemotingException {
workerRpcClient.send(Host.of(message.getMessageReceiverAddress()), message.convert2Command());
}
@Override
- public TaskExecuteResultCommand buildMessage(TaskExecutionContext taskExecutionContext) {
- TaskExecuteResultCommand taskExecuteResultMessage =
- new TaskExecuteResultCommand(workerConfig.getWorkerAddress(),
+ public TaskExecuteResultMessage buildMessage(TaskExecutionContext taskExecutionContext) {
+ TaskExecuteResultMessage taskExecuteResultMessage =
+ new TaskExecuteResultMessage(workerConfig.getWorkerAddress(),
taskExecutionContext.getWorkflowInstanceHost(),
System.currentTimeMillis());
taskExecuteResultMessage.setProcessInstanceId(taskExecutionContext.getProcessInstanceId());
@@ -64,7 +64,7 @@ public class TaskExecuteResultMessageSender implements MessageSender<TaskExecute
}
@Override
- public CommandType getMessageType() {
- return CommandType.TASK_EXECUTE_RESULT;
+ public MessageType getMessageType() {
+ return MessageType.TASK_EXECUTE_RESULT_MESSAGE;
}
}
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/TaskExecuteRunningMessageSender.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/TaskExecuteRunningMessageSender.java
index b4acc1446a..d879adfd11 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/TaskExecuteRunningMessageSender.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/TaskExecuteRunningMessageSender.java
@@ -18,8 +18,8 @@
package org.apache.dolphinscheduler.server.worker.message;
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
-import org.apache.dolphinscheduler.remote.command.CommandType;
-import org.apache.dolphinscheduler.remote.command.TaskExecuteRunningCommand;
+import org.apache.dolphinscheduler.remote.command.MessageType;
+import org.apache.dolphinscheduler.remote.command.task.TaskExecuteRunningMessage;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
import org.apache.dolphinscheduler.remote.utils.Host;
import org.apache.dolphinscheduler.server.worker.config.WorkerConfig;
@@ -31,7 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
-public class TaskExecuteRunningMessageSender implements MessageSender<TaskExecuteRunningCommand> {
+public class TaskExecuteRunningMessageSender implements MessageSender<TaskExecuteRunningMessage> {
@Autowired
private WorkerRpcClient workerRpcClient;
@@ -40,14 +40,14 @@ public class TaskExecuteRunningMessageSender implements MessageSender<TaskExecut
private WorkerConfig workerConfig;
@Override
- public void sendMessage(TaskExecuteRunningCommand message) throws RemotingException {
+ public void sendMessage(TaskExecuteRunningMessage message) throws RemotingException {
workerRpcClient.send(Host.of(message.getMessageReceiverAddress()), message.convert2Command());
}
@Override
- public TaskExecuteRunningCommand buildMessage(@NonNull TaskExecutionContext taskExecutionContext) {
- TaskExecuteRunningCommand taskExecuteRunningMessage =
- new TaskExecuteRunningCommand(workerConfig.getWorkerAddress(),
+ public TaskExecuteRunningMessage buildMessage(@NonNull TaskExecutionContext taskExecutionContext) {
+ TaskExecuteRunningMessage taskExecuteRunningMessage =
+ new TaskExecuteRunningMessage(workerConfig.getWorkerAddress(),
taskExecutionContext.getWorkflowInstanceHost(),
System.currentTimeMillis());
taskExecuteRunningMessage.setTaskInstanceId(taskExecutionContext.getTaskInstanceId());
@@ -62,7 +62,7 @@ public class TaskExecuteRunningMessageSender implements MessageSender<TaskExecut
}
@Override
- public CommandType getMessageType() {
- return CommandType.TASK_EXECUTE_RUNNING;
+ public MessageType getMessageType() {
+ return MessageType.TASK_EXECUTE_RUNNING_MESSAGE;
}
}
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/TaskRejectMessageSender.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/TaskRejectMessageSender.java
index 173b6f0842..25b2cfb66e 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/TaskRejectMessageSender.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/TaskRejectMessageSender.java
@@ -18,8 +18,8 @@
package org.apache.dolphinscheduler.server.worker.message;
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
-import org.apache.dolphinscheduler.remote.command.CommandType;
-import org.apache.dolphinscheduler.remote.command.TaskRejectCommand;
+import org.apache.dolphinscheduler.remote.command.MessageType;
+import org.apache.dolphinscheduler.remote.command.task.TaskRejectMessage;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
import org.apache.dolphinscheduler.remote.utils.Host;
import org.apache.dolphinscheduler.server.worker.config.WorkerConfig;
@@ -29,7 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
-public class TaskRejectMessageSender implements MessageSender<TaskRejectCommand> {
+public class TaskRejectMessageSender implements MessageSender<TaskRejectMessage> {
@Autowired
private WorkerRpcClient workerRpcClient;
@@ -38,13 +38,13 @@ public class TaskRejectMessageSender implements MessageSender<TaskRejectCommand>
private WorkerConfig workerConfig;
@Override
- public void sendMessage(TaskRejectCommand message) throws RemotingException {
+ public void sendMessage(TaskRejectMessage message) throws RemotingException {
workerRpcClient.send(Host.of(message.getMessageReceiverAddress()), message.convert2Command());
}
@Override
- public TaskRejectCommand buildMessage(TaskExecutionContext taskExecutionContext) {
- TaskRejectCommand taskRejectMessage = new TaskRejectCommand(workerConfig.getWorkerAddress(),
+ public TaskRejectMessage buildMessage(TaskExecutionContext taskExecutionContext) {
+ TaskRejectMessage taskRejectMessage = new TaskRejectMessage(workerConfig.getWorkerAddress(),
taskExecutionContext.getWorkflowInstanceHost(),
System.currentTimeMillis());
taskRejectMessage.setTaskInstanceId(taskExecutionContext.getTaskInstanceId());
@@ -54,7 +54,7 @@ public class TaskRejectMessageSender implements MessageSender<TaskRejectCommand>
}
@Override
- public CommandType getMessageType() {
- return CommandType.TASK_REJECT;
+ public MessageType getMessageType() {
+ return MessageType.TASK_REJECT;
}
}
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/TaskUpdatePidMessageSender.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/TaskUpdatePidMessageSender.java
index 8109ef5f64..9a5d434ede 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/TaskUpdatePidMessageSender.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/message/TaskUpdatePidMessageSender.java
@@ -18,8 +18,8 @@
package org.apache.dolphinscheduler.server.worker.message;
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
-import org.apache.dolphinscheduler.remote.command.CommandType;
-import org.apache.dolphinscheduler.remote.command.TaskUpdatePidCommand;
+import org.apache.dolphinscheduler.remote.command.MessageType;
+import org.apache.dolphinscheduler.remote.command.task.TaskUpdatePidMessage;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
import org.apache.dolphinscheduler.remote.utils.Host;
import org.apache.dolphinscheduler.server.worker.config.WorkerConfig;
@@ -31,7 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
-public class TaskUpdatePidMessageSender implements MessageSender<TaskUpdatePidCommand> {
+public class TaskUpdatePidMessageSender implements MessageSender<TaskUpdatePidMessage> {
@Autowired
private WorkerRpcClient workerRpcClient;
@@ -40,25 +40,25 @@ public class TaskUpdatePidMessageSender implements MessageSender<TaskUpdatePidCo
private WorkerConfig workerConfig;
@Override
- public void sendMessage(TaskUpdatePidCommand message) throws RemotingException {
+ public void sendMessage(TaskUpdatePidMessage message) throws RemotingException {
workerRpcClient.send(Host.of(message.getMessageReceiverAddress()), message.convert2Command());
}
@Override
- public TaskUpdatePidCommand buildMessage(@NonNull TaskExecutionContext taskExecutionContext) {
- TaskUpdatePidCommand taskUpdatePidCommand =
- new TaskUpdatePidCommand(workerConfig.getWorkerAddress(),
+ public TaskUpdatePidMessage buildMessage(@NonNull TaskExecutionContext taskExecutionContext) {
+ TaskUpdatePidMessage taskUpdatePidRequest =
+ new TaskUpdatePidMessage(workerConfig.getWorkerAddress(),
taskExecutionContext.getWorkflowInstanceHost(),
System.currentTimeMillis());
- taskUpdatePidCommand.setTaskInstanceId(taskExecutionContext.getTaskInstanceId());
- taskUpdatePidCommand.setProcessInstanceId(taskExecutionContext.getProcessInstanceId());
- taskUpdatePidCommand.setHost(taskExecutionContext.getHost());
- taskUpdatePidCommand.setStartTime(taskExecutionContext.getStartTime());
- return taskUpdatePidCommand;
+ taskUpdatePidRequest.setTaskInstanceId(taskExecutionContext.getTaskInstanceId());
+ taskUpdatePidRequest.setProcessInstanceId(taskExecutionContext.getProcessInstanceId());
+ taskUpdatePidRequest.setHost(taskExecutionContext.getHost());
+ taskUpdatePidRequest.setStartTime(taskExecutionContext.getStartTime());
+ return taskUpdatePidRequest;
}
@Override
- public CommandType getMessageType() {
- return CommandType.TASK_UPDATE_PID;
+ public MessageType getMessageType() {
+ return MessageType.TASK_UPDATE_PID_MESSAGE;
}
}
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskDispatchProcessor.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskDispatchProcessor.java
index 769f99e5fc..640c3641cc 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskDispatchProcessor.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskDispatchProcessor.java
@@ -17,8 +17,6 @@
package org.apache.dolphinscheduler.server.worker.processor;
-import static com.google.common.base.Preconditions.checkArgument;
-
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate;
@@ -27,9 +25,9 @@ import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContextCacheMana
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
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.TaskDispatchCommand;
+import org.apache.dolphinscheduler.remote.command.Message;
+import org.apache.dolphinscheduler.remote.command.MessageType;
+import org.apache.dolphinscheduler.remote.command.task.TaskDispatchMessage;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.worker.config.WorkerConfig;
import org.apache.dolphinscheduler.server.worker.metrics.TaskMetrics;
@@ -49,7 +47,7 @@ import io.micrometer.core.annotation.Timed;
import io.netty.channel.Channel;
/**
- * Used to handle {@link CommandType#TASK_DISPATCH_REQUEST}
+ * Used to handle {@link MessageType#TASK_DISPATCH_MESSAGE}
*/
@Component
@Slf4j
@@ -76,20 +74,17 @@ public class TaskDispatchProcessor implements NettyRequestProcessor {
@Counted(value = "ds.task.execution.count", description = "task execute total count")
@Timed(value = "ds.task.execution.duration", percentiles = {0.5, 0.75, 0.95, 0.99}, histogram = true)
@Override
- public void process(Channel channel, Command command) {
- checkArgument(CommandType.TASK_DISPATCH_REQUEST == command.getType(),
- String.format("invalid command type : %s", command.getType()));
-
- TaskDispatchCommand taskDispatchCommand = JSONUtils.parseObject(command.getBody(), TaskDispatchCommand.class);
+ public void process(Channel channel, Message message) {
+ TaskDispatchMessage taskDispatchMessage = JSONUtils.parseObject(message.getBody(), TaskDispatchMessage.class);
- if (taskDispatchCommand == null) {
+ if (taskDispatchMessage == null) {
log.error("task execute request command content is null");
return;
}
- final String workflowMasterAddress = taskDispatchCommand.getMessageSenderAddress();
- log.info("Receive task dispatch request, command: {}", taskDispatchCommand);
+ final String workflowMasterAddress = taskDispatchMessage.getMessageSenderAddress();
+ log.info("Receive task dispatch request, command: {}", taskDispatchMessage);
- TaskExecutionContext taskExecutionContext = taskDispatchCommand.getTaskExecutionContext();
+ TaskExecutionContext taskExecutionContext = taskDispatchMessage.getTaskExecutionContext();
if (taskExecutionContext == null) {
log.error("task execution context is null");
@@ -111,7 +106,7 @@ public class TaskDispatchProcessor implements NettyRequestProcessor {
if (remainTime > 0) {
log.info("Current taskInstance is choose delay execution, delay time: {}s", remainTime);
taskExecutionContext.setCurrentExecutionStatus(TaskExecutionStatus.DELAY_EXECUTION);
- workerMessageSender.sendMessage(taskExecutionContext, CommandType.TASK_EXECUTE_RESULT);
+ workerMessageSender.sendMessage(taskExecutionContext, MessageType.TASK_EXECUTE_RESULT_MESSAGE);
}
WorkerDelayTaskExecuteRunnable workerTaskExecuteRunnable = WorkerTaskExecuteRunnableFactoryBuilder
@@ -129,7 +124,7 @@ public class TaskDispatchProcessor implements NettyRequestProcessor {
log.warn(
"submit task to wait queue error, queue is full, current queue size is {}, will send a task reject message to master",
workerManager.getWaitSubmitQueueSize());
- workerMessageSender.sendMessageWithRetry(taskExecutionContext, CommandType.TASK_REJECT);
+ workerMessageSender.sendMessageWithRetry(taskExecutionContext, MessageType.TASK_REJECT);
} else {
log.info("Submit task to wait queue success, current queue size is {}",
workerManager.getWaitSubmitQueueSize());
@@ -137,4 +132,9 @@ public class TaskDispatchProcessor implements NettyRequestProcessor {
}
}
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.TASK_DISPATCH_MESSAGE;
+ }
+
}
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskExecuteResultAckProcessor.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskExecuteResultAckProcessor.java
index 43cb9da9a6..c5956c3112 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskExecuteResultAckProcessor.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskExecuteResultAckProcessor.java
@@ -19,9 +19,9 @@ package org.apache.dolphinscheduler.server.worker.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.TaskExecuteAckCommand;
+import org.apache.dolphinscheduler.remote.command.Message;
+import org.apache.dolphinscheduler.remote.command.MessageType;
+import org.apache.dolphinscheduler.remote.command.task.TaskExecuteResultMessageAck;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.worker.message.MessageRetryRunner;
@@ -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;
/**
@@ -44,34 +43,34 @@ public class TaskExecuteResultAckProcessor implements NettyRequestProcessor {
private MessageRetryRunner messageRetryRunner;
@Override
- public void process(Channel channel, Command command) {
- Preconditions.checkArgument(CommandType.TASK_EXECUTE_RESULT_ACK == command.getType(),
- String.format("invalid command type : %s", command.getType()));
-
- TaskExecuteAckCommand taskExecuteAckMessage = JSONUtils.parseObject(command.getBody(),
- TaskExecuteAckCommand.class);
+ public void process(Channel channel, Message message) {
+ TaskExecuteResultMessageAck taskExecuteAckMessage =
+ JSONUtils.parseObject(message.getBody(), TaskExecuteResultMessageAck.class);
if (taskExecuteAckMessage == null) {
log.error("task execute response ack command is null");
return;
}
- try {
- LogUtils.setTaskInstanceIdMDC(taskExecuteAckMessage.getTaskInstanceId());
+ try (
+ LogUtils.MDCAutoClosableContext mdcAutoClosableContext =
+ LogUtils.setTaskInstanceIdMDC(taskExecuteAckMessage.getTaskInstanceId())) {
log.info("Receive task execute response ack command : {}", taskExecuteAckMessage);
if (taskExecuteAckMessage.isSuccess()) {
messageRetryRunner.removeRetryMessage(taskExecuteAckMessage.getTaskInstanceId(),
- CommandType.TASK_EXECUTE_RESULT);
+ MessageType.TASK_EXECUTE_RESULT_MESSAGE);
log.debug("remove REMOTE_CHANNELS, task instance id:{}", taskExecuteAckMessage.getTaskInstanceId());
} else {
// master handle worker response error, will still retry
log.error("Receive task execute result ack message, the message status is not success, message: {}",
taskExecuteAckMessage);
}
- } finally {
- LogUtils.removeTaskInstanceIdMDC();
-
}
}
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.TASK_EXECUTE_RESULT_MESSAGE_ACK;
+ }
+
}
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskExecuteRunningAckProcessor.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskExecuteRunningAckProcessor.java
index f49a7c6129..1b561a6b13 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskExecuteRunningAckProcessor.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskExecuteRunningAckProcessor.java
@@ -19,9 +19,9 @@ package org.apache.dolphinscheduler.server.worker.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.TaskExecuteRunningAckMessage;
+import org.apache.dolphinscheduler.remote.command.Message;
+import org.apache.dolphinscheduler.remote.command.MessageType;
+import org.apache.dolphinscheduler.remote.command.task.TaskExecuteRunningMessageAck;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.worker.message.MessageRetryRunner;
@@ -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;
/**
@@ -44,12 +43,9 @@ public class TaskExecuteRunningAckProcessor implements NettyRequestProcessor {
private MessageRetryRunner messageRetryRunner;
@Override
- public void process(Channel channel, Command command) {
- Preconditions.checkArgument(CommandType.TASK_EXECUTE_RUNNING_ACK == command.getType(),
- String.format("invalid command type : %s", command.getType()));
-
- TaskExecuteRunningAckMessage runningAckCommand = JSONUtils.parseObject(command.getBody(),
- TaskExecuteRunningAckMessage.class);
+ public void process(Channel channel, Message message) {
+ TaskExecuteRunningMessageAck runningAckCommand = JSONUtils.parseObject(message.getBody(),
+ TaskExecuteRunningMessageAck.class);
if (runningAckCommand == null) {
log.error("task execute running ack command is null");
return;
@@ -60,11 +56,16 @@ public class TaskExecuteRunningAckProcessor implements NettyRequestProcessor {
if (runningAckCommand.isSuccess()) {
messageRetryRunner.removeRetryMessage(runningAckCommand.getTaskInstanceId(),
- CommandType.TASK_EXECUTE_RUNNING);
+ MessageType.TASK_EXECUTE_RUNNING_MESSAGE);
}
} finally {
LogUtils.removeTaskInstanceIdMDC();
}
}
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.TASK_EXECUTE_RUNNING_MESSAGE_ACK;
+ }
+
}
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskKillProcessor.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskKillProcessor.java
index 6421dc7490..a68ff86fb4 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskKillProcessor.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskKillProcessor.java
@@ -27,10 +27,10 @@ import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContextCacheMana
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.ProcessUtils;
-import org.apache.dolphinscheduler.remote.command.Command;
-import org.apache.dolphinscheduler.remote.command.CommandType;
-import org.apache.dolphinscheduler.remote.command.TaskKillRequestCommand;
-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.TaskKillRequest;
+import org.apache.dolphinscheduler.remote.command.task.TaskKillResponse;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.worker.message.MessageRetryRunner;
import org.apache.dolphinscheduler.server.worker.runner.WorkerManagerThread;
@@ -43,11 +43,9 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import io.netty.channel.Channel;
-import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
/**
@@ -67,13 +65,11 @@ public class TaskKillProcessor implements NettyRequestProcessor {
* task kill process
*
* @param channel channel channel
- * @param command command command
+ * @param message command command
*/
@Override
- public void process(Channel channel, Command command) {
- Preconditions.checkArgument(CommandType.TASK_KILL_REQUEST == command.getType(),
- String.format("invalid command type : %s", command.getType()));
- TaskKillRequestCommand killCommand = JSONUtils.parseObject(command.getBody(), TaskKillRequestCommand.class);
+ public void process(Channel channel, Message message) {
+ TaskKillRequest killCommand = JSONUtils.parseObject(message.getBody(), TaskKillRequest.class);
if (killCommand == null) {
log.error("task kill request command is null");
return;
@@ -96,7 +92,7 @@ public class TaskKillProcessor implements NettyRequestProcessor {
workerManager.killTaskBeforeExecuteByInstanceId(taskInstanceId);
taskExecutionContext.setCurrentExecutionStatus(TaskExecutionStatus.KILL);
TaskExecutionContextCacheManager.removeByTaskInstanceId(taskInstanceId);
- sendTaskKillResponseCommand(channel, taskExecutionContext);
+ sendTaskKillResponseCommand(channel, message.getOpaque(), taskExecutionContext);
log.info("the task has not been executed and has been cancelled, task id:{}", taskInstanceId);
return;
}
@@ -107,7 +103,7 @@ public class TaskKillProcessor implements NettyRequestProcessor {
taskExecutionContext.setCurrentExecutionStatus(
result ? TaskExecutionStatus.SUCCESS : TaskExecutionStatus.FAILURE);
- sendTaskKillResponseCommand(channel, taskExecutionContext);
+ sendTaskKillResponseCommand(channel, message.getOpaque(), taskExecutionContext);
TaskExecutionContextCacheManager.removeByTaskInstanceId(taskExecutionContext.getTaskInstanceId());
messageRetryRunner.removeRetryMessages(taskExecutionContext.getTaskInstanceId());
@@ -118,23 +114,24 @@ public class TaskKillProcessor implements NettyRequestProcessor {
}
}
- private void sendTaskKillResponseCommand(Channel channel, TaskExecutionContext taskExecutionContext) {
- TaskKillResponseCommand taskKillResponseCommand = new TaskKillResponseCommand();
- taskKillResponseCommand.setStatus(taskExecutionContext.getCurrentExecutionStatus());
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.TASK_KILL_REQUEST;
+ }
+
+ private void sendTaskKillResponseCommand(Channel channel, long opaque, TaskExecutionContext taskExecutionContext) {
+ TaskKillResponse taskKillResponse = new TaskKillResponse();
+ taskKillResponse.setStatus(taskExecutionContext.getCurrentExecutionStatus());
if (taskExecutionContext.getAppIds() != null) {
- taskKillResponseCommand
+ taskKillResponse
.setAppIds(Arrays.asList(taskExecutionContext.getAppIds().split(TaskConstants.COMMA)));
}
- taskKillResponseCommand.setTaskInstanceId(taskExecutionContext.getTaskInstanceId());
- taskKillResponseCommand.setHost(taskExecutionContext.getHost());
- taskKillResponseCommand.setProcessId(taskExecutionContext.getProcessId());
- channel.writeAndFlush(taskKillResponseCommand.convert2Command()).addListener(new ChannelFutureListener() {
-
- @Override
- public void operationComplete(ChannelFuture future) throws Exception {
- if (!future.isSuccess()) {
- log.error("Submit kill response to master error, kill command: {}", taskKillResponseCommand);
- }
+ taskKillResponse.setTaskInstanceId(taskExecutionContext.getTaskInstanceId());
+ taskKillResponse.setHost(taskExecutionContext.getHost());
+ taskKillResponse.setProcessId(taskExecutionContext.getProcessId());
+ channel.writeAndFlush(taskKillResponse.convert2Command(opaque)).addListener((ChannelFutureListener) future -> {
+ if (!future.isSuccess()) {
+ log.error("Submit kill response to master error, kill command: {}", taskKillResponse);
}
});
}
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskRejectAckProcessor.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskRejectAckProcessor.java
index 7bc1267907..de941d3742 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskRejectAckProcessor.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskRejectAckProcessor.java
@@ -19,9 +19,9 @@ package org.apache.dolphinscheduler.server.worker.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.TaskRejectAckCommand;
+import org.apache.dolphinscheduler.remote.command.Message;
+import org.apache.dolphinscheduler.remote.command.MessageType;
+import org.apache.dolphinscheduler.remote.command.task.TaskRejectMessageAck;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.worker.message.MessageRetryRunner;
@@ -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;
@Component
@@ -41,30 +40,33 @@ public class TaskRejectAckProcessor implements NettyRequestProcessor {
private MessageRetryRunner messageRetryRunner;
@Override
- public void process(Channel channel, Command command) {
- Preconditions.checkArgument(CommandType.TASK_REJECT_ACK == command.getType(),
- String.format("invalid command type : %s", command.getType()));
+ public void process(Channel channel, Message message) {
- TaskRejectAckCommand taskRejectAckMessage = JSONUtils.parseObject(command.getBody(),
- TaskRejectAckCommand.class);
- if (taskRejectAckMessage == null) {
+ TaskRejectMessageAck taskRejectMessageAck =
+ JSONUtils.parseObject(message.getBody(), TaskRejectMessageAck.class);
+ if (taskRejectMessageAck == null) {
log.error("Receive task reject response, the response message is null");
return;
}
try {
- LogUtils.setTaskInstanceIdMDC(taskRejectAckMessage.getTaskInstanceId());
- log.info("Receive task reject response ack command: {}", taskRejectAckMessage);
- if (taskRejectAckMessage.isSuccess()) {
- messageRetryRunner.removeRetryMessage(taskRejectAckMessage.getTaskInstanceId(),
- CommandType.TASK_REJECT);
- log.debug("removeRecallCache: task instance id:{}", taskRejectAckMessage.getTaskInstanceId());
+ LogUtils.setTaskInstanceIdMDC(taskRejectMessageAck.getTaskInstanceId());
+ log.info("Receive task reject response ack command: {}", taskRejectMessageAck);
+ if (taskRejectMessageAck.isSuccess()) {
+ messageRetryRunner.removeRetryMessage(taskRejectMessageAck.getTaskInstanceId(),
+ MessageType.TASK_REJECT);
+ log.debug("removeRecallCache: task instance id:{}", taskRejectMessageAck.getTaskInstanceId());
} else {
log.error("Receive task reject ack message, the message status is not success, message: {}",
- taskRejectAckMessage);
+ taskRejectMessageAck);
}
} finally {
LogUtils.removeTaskInstanceIdMDC();
}
}
+
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.TASK_REJECT_MESSAGE_ACK;
+ }
}
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskSavePointProcessor.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskSavePointProcessor.java
index 7d3008a921..33c8dacf7c 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskSavePointProcessor.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskSavePointProcessor.java
@@ -23,10 +23,10 @@ import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContextCacheManager;
import org.apache.dolphinscheduler.plugin.task.api.stream.StreamTask;
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.TaskSavePointRequestCommand;
-import org.apache.dolphinscheduler.remote.command.TaskSavePointResponseCommand;
+import org.apache.dolphinscheduler.remote.command.Message;
+import org.apache.dolphinscheduler.remote.command.MessageType;
+import org.apache.dolphinscheduler.remote.command.task.TaskSavePointRequest;
+import org.apache.dolphinscheduler.remote.command.task.TaskSavePointResponse;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.worker.runner.WorkerManagerThread;
import org.apache.dolphinscheduler.server.worker.runner.WorkerTaskExecuteRunnable;
@@ -36,8 +36,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;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
@@ -59,26 +57,24 @@ public class TaskSavePointProcessor implements NettyRequestProcessor {
* task save point process
*
* @param channel channel channel
- * @param command command command
+ * @param message command command
*/
@Override
- public void process(Channel channel, Command command) {
- Preconditions.checkArgument(CommandType.TASK_SAVEPOINT_REQUEST == command.getType(),
- String.format("invalid command type : %s", command.getType()));
- TaskSavePointRequestCommand taskSavePointRequestCommand =
- JSONUtils.parseObject(command.getBody(), TaskSavePointRequestCommand.class);
- if (taskSavePointRequestCommand == null) {
+ public void process(Channel channel, Message message) {
+ TaskSavePointRequest taskSavePointRequest =
+ JSONUtils.parseObject(message.getBody(), TaskSavePointRequest.class);
+ if (taskSavePointRequest == null) {
log.error("task savepoint request command is null");
return;
}
- log.info("Receive task savepoint command : {}", taskSavePointRequestCommand);
+ log.info("Receive task savepoint command : {}", taskSavePointRequest);
- int taskInstanceId = taskSavePointRequestCommand.getTaskInstanceId();
+ int taskInstanceId = taskSavePointRequest.getTaskInstanceId();
TaskExecutionContext taskExecutionContext =
TaskExecutionContextCacheManager.getByTaskInstanceId(taskInstanceId);
if (taskExecutionContext == null) {
log.error("taskRequest cache is null, taskInstanceId: {}",
- taskSavePointRequestCommand.getTaskInstanceId());
+ taskSavePointRequest.getTaskInstanceId());
return;
}
@@ -92,19 +88,24 @@ public class TaskSavePointProcessor implements NettyRequestProcessor {
}
}
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.TASK_SAVEPOINT_REQUEST;
+ }
+
private void sendTaskSavePointResponseCommand(Channel channel, TaskExecutionContext taskExecutionContext) {
- TaskSavePointResponseCommand taskSavePointResponseCommand = new TaskSavePointResponseCommand();
- taskSavePointResponseCommand.setTaskInstanceId(taskExecutionContext.getTaskInstanceId());
- channel.writeAndFlush(taskSavePointResponseCommand.convert2Command()).addListener(new ChannelFutureListener() {
+ TaskSavePointResponse taskSavePointResponse = new TaskSavePointResponse();
+ taskSavePointResponse.setTaskInstanceId(taskExecutionContext.getTaskInstanceId());
+ channel.writeAndFlush(taskSavePointResponse.convert2Command()).addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (!future.isSuccess()) {
log.error("Submit kill response to master error, kill command: {}",
- taskSavePointResponseCommand);
+ taskSavePointResponse);
} else
log.info("Submit kill response to master success, kill command: {}",
- taskSavePointResponseCommand);
+ taskSavePointResponse);
}
});
}
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskUpdatePidAckProcessor.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskUpdatePidAckProcessor.java
index af3680d0eb..0465f7d0b4 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskUpdatePidAckProcessor.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskUpdatePidAckProcessor.java
@@ -19,9 +19,9 @@ package org.apache.dolphinscheduler.server.worker.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.TaskUpdatePidAckMessage;
+import org.apache.dolphinscheduler.remote.command.Message;
+import org.apache.dolphinscheduler.remote.command.MessageType;
+import org.apache.dolphinscheduler.remote.command.task.TaskUpdatePidAckMessage;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.worker.message.MessageRetryRunner;
@@ -31,7 +31,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
-import com.google.common.base.Preconditions;
import io.netty.channel.Channel;
/**
@@ -45,11 +44,9 @@ public class TaskUpdatePidAckProcessor implements NettyRequestProcessor {
private MessageRetryRunner messageRetryRunner;
@Override
- public void process(Channel channel, Command command) {
- Preconditions.checkArgument(CommandType.TASK_UPDATE_PID_ACK == command.getType(),
- String.format("invalid command type : %s", command.getType()));
+ public void process(Channel channel, Message message) {
- TaskUpdatePidAckMessage updatePidAckCommand = JSONUtils.parseObject(command.getBody(),
+ TaskUpdatePidAckMessage updatePidAckCommand = JSONUtils.parseObject(message.getBody(),
TaskUpdatePidAckMessage.class);
if (updatePidAckCommand == null) {
log.error("task execute update pid ack command is null");
@@ -61,11 +58,16 @@ public class TaskUpdatePidAckProcessor implements NettyRequestProcessor {
if (updatePidAckCommand.isSuccess()) {
messageRetryRunner.removeRetryMessage(updatePidAckCommand.getTaskInstanceId(),
- CommandType.TASK_UPDATE_PID);
+ MessageType.TASK_UPDATE_PID_MESSAGE);
}
} finally {
LogUtils.removeTaskInstanceIdMDC();
}
}
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.TASK_UPDATE_PID__MESSAGE_ACK;
+ }
+
}
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/WorkflowHostChangeProcessor.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/WorkflowHostChangeProcessor.java
index 33da734151..8859b3efe9 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/WorkflowHostChangeProcessor.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/WorkflowHostChangeProcessor.java
@@ -21,8 +21,8 @@ import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContextCacheManager;
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.Message;
+import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.command.task.WorkflowHostChangeRequest;
import org.apache.dolphinscheduler.remote.command.task.WorkflowHostChangeResponse;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
@@ -33,8 +33,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import com.google.common.base.Preconditions;
-
import io.netty.channel.Channel;
import io.netty.channel.ChannelFutureListener;
@@ -51,11 +49,9 @@ public class WorkflowHostChangeProcessor implements NettyRequestProcessor {
private MessageRetryRunner messageRetryRunner;
@Override
- public void process(Channel channel, Command command) {
- Preconditions.checkArgument(CommandType.WORKFLOW_HOST_CHANGE_REQUEST == command.getType(),
- String.format("invalid command type : %s", command.getType()));
+ public void process(Channel channel, Message message) {
WorkflowHostChangeRequest workflowHostChangeRequest =
- JSONUtils.parseObject(command.getBody(), WorkflowHostChangeRequest.class);
+ JSONUtils.parseObject(message.getBody(), WorkflowHostChangeRequest.class);
if (workflowHostChangeRequest == null) {
logger.error("host update command is null");
return;
@@ -79,7 +75,7 @@ public class WorkflowHostChangeProcessor implements NettyRequestProcessor {
logger.error("Cannot find the taskExecutionContext, taskInstanceId : {}",
workflowHostChangeRequest.getTaskInstanceId());
}
- channel.writeAndFlush(workflowHostChangeResponse.convert2Command(command.getOpaque())).addListener(
+ channel.writeAndFlush(workflowHostChangeResponse.convert2Command(message.getOpaque())).addListener(
(ChannelFutureListener) channelFuture -> {
if (!channelFuture.isSuccess()) {
logger.error("send host update response failed");
@@ -88,4 +84,9 @@ public class WorkflowHostChangeProcessor implements NettyRequestProcessor {
}
}
+ @Override
+ public MessageType getCommandType() {
+ return MessageType.WORKFLOW_HOST_CHANGE_REQUEST;
+ }
+
}
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/rpc/WorkerMessageSender.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/rpc/WorkerMessageSender.java
index f61bb332e7..a8b892fbaf 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/rpc/WorkerMessageSender.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/rpc/WorkerMessageSender.java
@@ -18,8 +18,8 @@
package org.apache.dolphinscheduler.server.worker.rpc;
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
-import org.apache.dolphinscheduler.remote.command.BaseCommand;
-import org.apache.dolphinscheduler.remote.command.CommandType;
+import org.apache.dolphinscheduler.remote.command.BaseMessage;
+import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
import org.apache.dolphinscheduler.server.worker.message.MessageRetryRunner;
import org.apache.dolphinscheduler.server.worker.message.MessageSender;
@@ -46,7 +46,7 @@ public class WorkerMessageSender {
@Autowired
private List<MessageSender> messageSenders;
- private Map<CommandType, MessageSender> messageSenderMap = new HashMap<>();
+ private Map<MessageType, MessageSender> messageSenderMap = new HashMap<>();
@PostConstruct
public void init() {
@@ -56,30 +56,30 @@ public class WorkerMessageSender {
// todo: use message rather than context
public void sendMessageWithRetry(@NonNull TaskExecutionContext taskExecutionContext,
- @NonNull CommandType messageType) {
+ @NonNull MessageType messageType) {
MessageSender messageSender = messageSenderMap.get(messageType);
if (messageSender == null) {
throw new IllegalArgumentException("The messageType is invalidated, messageType: " + messageType);
}
- BaseCommand baseCommand = messageSender.buildMessage(taskExecutionContext);
+ BaseMessage baseMessage = messageSender.buildMessage(taskExecutionContext);
try {
- messageRetryRunner.addRetryMessage(taskExecutionContext.getTaskInstanceId(), messageType, baseCommand);
- messageSender.sendMessage(baseCommand);
+ messageRetryRunner.addRetryMessage(taskExecutionContext.getTaskInstanceId(), messageType, baseMessage);
+ messageSender.sendMessage(baseMessage);
} catch (RemotingException e) {
- log.error("Send message error, messageType: {}, message: {}", messageType, baseCommand);
+ log.error("Send message error, messageType: {}, message: {}", messageType, baseMessage);
}
}
- public void sendMessage(@NonNull TaskExecutionContext taskExecutionContext, @NonNull CommandType messageType) {
+ public void sendMessage(@NonNull TaskExecutionContext taskExecutionContext, @NonNull MessageType messageType) {
MessageSender messageSender = messageSenderMap.get(messageType);
if (messageSender == null) {
throw new IllegalArgumentException("The messageType is invalidated, messageType: " + messageType);
}
- BaseCommand baseCommand = messageSender.buildMessage(taskExecutionContext);
+ BaseMessage baseMessage = messageSender.buildMessage(taskExecutionContext);
try {
- messageSender.sendMessage(baseCommand);
+ messageSender.sendMessage(baseMessage);
} catch (RemotingException e) {
- log.error("Send message error, messageType: {}, message: {}", messageType, baseCommand);
+ log.error("Send message error, messageType: {}, message: {}", messageType, baseMessage);
}
}
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/rpc/WorkerRpcClient.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/rpc/WorkerRpcClient.java
index a6c7063622..41fdd93992 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/rpc/WorkerRpcClient.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/rpc/WorkerRpcClient.java
@@ -18,21 +18,18 @@
package org.apache.dolphinscheduler.server.worker.rpc;
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.exceptions.RemotingException;
+import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.remote.utils.Host;
-import org.apache.dolphinscheduler.server.worker.processor.TaskExecuteResultAckProcessor;
-import org.apache.dolphinscheduler.server.worker.processor.TaskExecuteRunningAckProcessor;
-import org.apache.dolphinscheduler.server.worker.processor.TaskRejectAckProcessor;
-import org.apache.dolphinscheduler.server.worker.processor.TaskUpdatePidAckProcessor;
-import javax.annotation.Resource;
+import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
@@ -43,16 +40,8 @@ import org.springframework.stereotype.Component;
public class WorkerRpcClient implements AutoCloseable {
@Autowired
- private TaskExecuteRunningAckProcessor taskExecuteRunningAckProcessor;
-
- @Autowired
- private TaskExecuteResultAckProcessor taskExecuteResultAckProcessor;
-
- @Resource
- private TaskUpdatePidAckProcessor taskUpdatePidAckProcessor;
-
- @Autowired
- private TaskRejectAckProcessor taskRejectAckProcessor;
+ @Lazy
+ private List<NettyRequestProcessor> nettyRequestProcessors;
private NettyRemotingClient nettyRemotingClient;
@@ -61,17 +50,15 @@ public class WorkerRpcClient implements AutoCloseable {
NettyClientConfig nettyClientConfig = new NettyClientConfig();
this.nettyRemotingClient = new NettyRemotingClient(nettyClientConfig);
// we only use the client to handle the ack message, we can optimize this, send ack to the nettyServer.
- this.nettyRemotingClient.registerProcessor(CommandType.TASK_EXECUTE_RUNNING_ACK,
- taskExecuteRunningAckProcessor);
- this.nettyRemotingClient.registerProcessor(CommandType.TASK_UPDATE_PID_ACK,
- taskUpdatePidAckProcessor);
- this.nettyRemotingClient.registerProcessor(CommandType.TASK_EXECUTE_RESULT_ACK, taskExecuteResultAckProcessor);
- this.nettyRemotingClient.registerProcessor(CommandType.TASK_REJECT_ACK, taskRejectAckProcessor);
+ for (NettyRequestProcessor nettyRequestProcessor : nettyRequestProcessors) {
+ this.nettyRemotingClient.registerProcessor(nettyRequestProcessor);
+
+ }
log.info("Worker rpc client started");
}
- 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);
}
public void close() {
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/rpc/WorkerRpcServer.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/rpc/WorkerRpcServer.java
index f9d64e6551..eac13d273e 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/rpc/WorkerRpcServer.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/rpc/WorkerRpcServer.java
@@ -18,22 +18,12 @@
package org.apache.dolphinscheduler.server.worker.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.worker.config.WorkerConfig;
-import org.apache.dolphinscheduler.server.worker.processor.TaskDispatchProcessor;
-import org.apache.dolphinscheduler.server.worker.processor.TaskExecuteResultAckProcessor;
-import org.apache.dolphinscheduler.server.worker.processor.TaskExecuteRunningAckProcessor;
-import org.apache.dolphinscheduler.server.worker.processor.TaskKillProcessor;
-import org.apache.dolphinscheduler.server.worker.processor.TaskRejectAckProcessor;
-import org.apache.dolphinscheduler.server.worker.processor.TaskSavePointProcessor;
-import org.apache.dolphinscheduler.server.worker.processor.TaskUpdatePidAckProcessor;
-import org.apache.dolphinscheduler.server.worker.processor.WorkflowHostChangeProcessor;
import java.io.Closeable;
-
-import javax.annotation.Resource;
+import java.util.List;
import lombok.extern.slf4j.Slf4j;
@@ -45,31 +35,7 @@ import org.springframework.stereotype.Service;
public class WorkerRpcServer implements Closeable {
@Autowired
- private TaskDispatchProcessor taskDispatchProcessor;
-
- @Autowired
- private TaskKillProcessor taskKillProcessor;
-
- @Autowired
- private TaskRejectAckProcessor taskRejectAckProcessor;
-
- @Autowired
- private TaskSavePointProcessor taskSavePointProcessor;
-
- @Autowired
- private TaskExecuteRunningAckProcessor taskExecuteRunningAckProcessor;
-
- @Resource
- private TaskUpdatePidAckProcessor taskUpdatePidAckProcessor;
-
- @Autowired
- private TaskExecuteResultAckProcessor taskExecuteResultAckProcessor;
-
- @Autowired
- private WorkflowHostChangeProcessor workflowHostChangeProcessor;
-
- @Autowired
- private LoggerRequestProcessor loggerRequestProcessor;
+ private List<NettyRequestProcessor> nettyRequestProcessors;
@Autowired
private WorkerConfig workerConfig;
@@ -79,25 +45,12 @@ public class WorkerRpcServer implements Closeable {
public void start() {
log.info("Worker rpc server starting");
NettyServerConfig serverConfig = new NettyServerConfig();
+ nettyRemotingServer = new NettyRemotingServer(serverConfig);
serverConfig.setListenPort(workerConfig.getListenPort());
- this.nettyRemotingServer = new NettyRemotingServer(serverConfig);
- this.nettyRemotingServer.registerProcessor(CommandType.TASK_DISPATCH_REQUEST, taskDispatchProcessor);
- this.nettyRemotingServer.registerProcessor(CommandType.TASK_KILL_REQUEST, taskKillProcessor);
- this.nettyRemotingServer.registerProcessor(CommandType.TASK_EXECUTE_RUNNING_ACK,
- taskExecuteRunningAckProcessor);
- this.nettyRemotingServer.registerProcessor(CommandType.TASK_UPDATE_PID_ACK,
- taskUpdatePidAckProcessor);
- this.nettyRemotingServer.registerProcessor(CommandType.TASK_EXECUTE_RESULT_ACK, taskExecuteResultAckProcessor);
- this.nettyRemotingServer.registerProcessor(CommandType.TASK_REJECT_ACK, taskRejectAckProcessor);
- this.nettyRemotingServer.registerProcessor(CommandType.WORKFLOW_HOST_CHANGE_REQUEST,
- workflowHostChangeProcessor);
- this.nettyRemotingServer.registerProcessor(CommandType.TASK_SAVEPOINT_REQUEST, taskSavePointProcessor);
- // log server
- this.nettyRemotingServer.registerProcessor(CommandType.GET_APP_ID_REQUEST, loggerRequestProcessor);
- 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) {
+ nettyRemotingServer.registerProcessor(nettyRequestProcessor);
+ log.info("Success register netty processor: {}", nettyRequestProcessor.getClass().getName());
+ }
this.nettyRemotingServer.start();
log.info("Worker rpc server started");
}
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskCallbackImpl.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskCallbackImpl.java
index b286902772..9dba2bf8cd 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskCallbackImpl.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskCallbackImpl.java
@@ -21,7 +21,7 @@ import org.apache.dolphinscheduler.plugin.task.api.TaskCallBack;
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContextCacheManager;
import org.apache.dolphinscheduler.plugin.task.api.model.ApplicationInfo;
-import org.apache.dolphinscheduler.remote.command.CommandType;
+import org.apache.dolphinscheduler.remote.command.MessageType;
import org.apache.dolphinscheduler.server.worker.rpc.WorkerMessageSender;
import lombok.Builder;
@@ -52,7 +52,7 @@ public class TaskCallbackImpl implements TaskCallBack {
log.info("send remote application info {}", applicationInfo);
taskExecutionContext.setAppIds(applicationInfo.getAppIds());
- workerMessageSender.sendMessageWithRetry(taskExecutionContext, CommandType.TASK_EXECUTE_RUNNING);
+ workerMessageSender.sendMessageWithRetry(taskExecutionContext, MessageType.TASK_EXECUTE_RUNNING_MESSAGE);
}
@Override
@@ -64,7 +64,7 @@ public class TaskCallbackImpl implements TaskCallBack {
return;
}
- workerMessageSender.sendMessageWithRetry(taskExecutionContext, CommandType.TASK_UPDATE_PID);
+ workerMessageSender.sendMessageWithRetry(taskExecutionContext, MessageType.TASK_UPDATE_PID_MESSAGE);
}
}
diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/WorkerTaskExecuteRunnable.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/WorkerTaskExecuteRunnable.java
index cfaab86f1b..d13043b4a1 100644
--- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/WorkerTaskExecuteRunnable.java
+++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/WorkerTaskExecuteRunnable.java
@@ -38,8 +38,8 @@ import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.plugin.task.api.model.TaskAlertInfo;
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.ProcessUtils;
-import org.apache.dolphinscheduler.remote.command.CommandType;
-import org.apache.dolphinscheduler.remote.command.alert.AlertSendRequestCommand;
+import org.apache.dolphinscheduler.remote.command.MessageType;
+import org.apache.dolphinscheduler.remote.command.alert.AlertSendRequest;
import org.apache.dolphinscheduler.remote.exceptions.RemotingException;
import org.apache.dolphinscheduler.remote.utils.Host;
import org.apache.dolphinscheduler.server.worker.config.WorkerConfig;
@@ -111,7 +111,7 @@ public abstract class WorkerTaskExecuteRunnable implements Runnable {
TaskExecutionContextCacheManager.removeByTaskInstanceId(taskExecutionContext.getTaskInstanceId());
taskExecutionContext.setCurrentExecutionStatus(TaskExecutionStatus.FAILURE);
taskExecutionContext.setEndTime(System.currentTimeMillis());
- workerMessageSender.sendMessageWithRetry(taskExecutionContext, CommandType.TASK_EXECUTE_RESULT);
+ workerMessageSender.sendMessageWithRetry(taskExecutionContext, MessageType.TASK_EXECUTE_RESULT_MESSAGE);
log.info(
"Get a exception when execute the task, will send the task execute result to master, the current task execute result is {}",
TaskExecutionStatus.FAILURE);
@@ -146,7 +146,7 @@ public abstract class WorkerTaskExecuteRunnable implements Runnable {
taskExecutionContext.setCurrentExecutionStatus(TaskExecutionStatus.SUCCESS);
taskExecutionContext.setEndTime(System.currentTimeMillis());
TaskExecutionContextCacheManager.removeByTaskInstanceId(taskExecutionContext.getTaskInstanceId());
- workerMessageSender.sendMessageWithRetry(taskExecutionContext, CommandType.TASK_EXECUTE_RESULT);
+ workerMessageSender.sendMessageWithRetry(taskExecutionContext, MessageType.TASK_EXECUTE_RESULT_MESSAGE);
log.info(
"The current execute mode is dry run, will stop the subsequent process and set the taskInstance status to success");
return;
@@ -189,7 +189,7 @@ public abstract class WorkerTaskExecuteRunnable implements Runnable {
protected void beforeExecute() {
taskExecutionContext.setCurrentExecutionStatus(TaskExecutionStatus.RUNNING_EXECUTION);
- workerMessageSender.sendMessageWithRetry(taskExecutionContext, CommandType.TASK_EXECUTE_RUNNING);
+ workerMessageSender.sendMessageWithRetry(taskExecutionContext, MessageType.TASK_EXECUTE_RUNNING_MESSAGE);
log.info("Set task status to {}", TaskExecutionStatus.RUNNING_EXECUTION);
TaskExecutionCheckerUtils.checkTenantExist(workerConfig, taskExecutionContext);
@@ -232,7 +232,7 @@ public abstract class WorkerTaskExecuteRunnable implements Runnable {
TaskAlertInfo taskAlertInfo = task.getTaskAlertInfo();
int strategy =
status == TaskExecutionStatus.SUCCESS ? WarningType.SUCCESS.getCode() : WarningType.FAILURE.getCode();
- AlertSendRequestCommand alertCommand = new AlertSendRequestCommand(
+ AlertSendRequest alertCommand = new AlertSendRequest(
taskAlertInfo.getAlertGroupId(),
taskAlertInfo.getTitle(),
taskAlertInfo.getContent(),
@@ -253,7 +253,7 @@ public abstract class WorkerTaskExecuteRunnable implements Runnable {
taskExecutionContext.setVarPool(JSONUtils.toJsonString(task.getParameters().getVarPool()));
// upload out files and modify the "OUT FILE" property in VarPool
TaskFilesTransferUtils.uploadOutputFiles(taskExecutionContext, storageOperate);
- workerMessageSender.sendMessageWithRetry(taskExecutionContext, CommandType.TASK_EXECUTE_RESULT);
+ workerMessageSender.sendMessageWithRetry(taskExecutionContext, MessageType.TASK_EXECUTE_RESULT_MESSAGE);
log.info("Send task execute result to master, the current task status: {}",
taskExecutionContext.getCurrentExecutionStatus());
diff --git a/dolphinscheduler-worker/src/test/java/org/apache/dolphinscheduler/server/worker/processor/TaskDispatchProcessorTest.java b/dolphinscheduler-worker/src/test/java/org/apache/dolphinscheduler/server/worker/processor/TaskDispatchProcessorTest.java
index 9276b7b3c4..2e0604f9c5 100644
--- a/dolphinscheduler-worker/src/test/java/org/apache/dolphinscheduler/server/worker/processor/TaskDispatchProcessorTest.java
+++ b/dolphinscheduler-worker/src/test/java/org/apache/dolphinscheduler/server/worker/processor/TaskDispatchProcessorTest.java
@@ -20,9 +20,9 @@ package org.apache.dolphinscheduler.server.worker.processor;
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate;
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager;
-import org.apache.dolphinscheduler.remote.command.Command;
-import org.apache.dolphinscheduler.remote.command.CommandType;
-import org.apache.dolphinscheduler.remote.command.TaskDispatchCommand;
+import org.apache.dolphinscheduler.remote.command.Message;
+import org.apache.dolphinscheduler.remote.command.MessageType;
+import org.apache.dolphinscheduler.remote.command.task.TaskDispatchMessage;
import org.apache.dolphinscheduler.server.worker.config.WorkerConfig;
import org.apache.dolphinscheduler.server.worker.rpc.WorkerMessageSender;
import org.apache.dolphinscheduler.server.worker.rpc.WorkerRpcClient;
@@ -68,16 +68,16 @@ public class TaskDispatchProcessorTest {
public void process() {
Channel channel = Mockito.mock(Channel.class);
TaskExecutionContext taskExecutionContext = getTaskExecutionContext();
- Command dispatchCommand = createDispatchCommand(taskExecutionContext);
- taskDispatchProcessor.process(channel, dispatchCommand);
+ Message dispatchMessage = createDispatchCommand(taskExecutionContext);
+ taskDispatchProcessor.process(channel, dispatchMessage);
Mockito.verify(workerManagerThread, Mockito.atMostOnce()).offer(Mockito.any());
Mockito.verify(workerMessageSender, Mockito.never()).sendMessageWithRetry(taskExecutionContext,
- CommandType.TASK_REJECT);
+ MessageType.TASK_REJECT);
}
- public Command createDispatchCommand(TaskExecutionContext taskExecutionContext) {
- return new TaskDispatchCommand(
+ public Message createDispatchCommand(TaskExecutionContext taskExecutionContext) {
+ return new TaskDispatchMessage(
taskExecutionContext,
"localhost:5678",
"localhost:1234",